﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Text.RegularExpressions;
using System.Threading;
using System.Reflection; // 引用这个才能使用Missing字段
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Xml;
using System.Web;
using System.Runtime.InteropServices;
using System.Net.Sockets;
using System.Net;
using System.IO;
using CCWin;
using Newtonsoft.Json;
using LitJson;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;



namespace weiqijiance.联网通信协议
{


    public class LWyunjing : LWbass
    {
        public LWyunjing()
        {
        }
        socketyunjing objsocket = new socketyunjing();
        public LWyunjing(string surl)
        {
            objdb = new 数据库操作.DBweiqi();
            try
            {
                string[] surls = surl.Split(':');
                string sip = surls[0];
                int iport = 0;
                int.TryParse(surls[1], out iport);
                objsocket.connect(sip, iport);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public override void setmainform(mainform m_m)
        {
            base.setmainform(m_m);
            try
            {
                string str = connetzhuche();
                if (str.Substring(0, str.IndexOf(',')) == "0")
                {
                    MessageBox.Show(str);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //public mainform m_mainform;// { get; set; }
        //云景联网内容
        public string Post(string Url, string Data, string Referer)//数据发送
        {
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
            //request.Method = "POST";
            //byte[] bytes = Encoding.UTF8.GetBytes(Data);
            //request.ContentType = "application/json; charset=UTF-8";
            //request.ContentLength = bytes.Length;
            //Stream myResponseStream = request.GetRequestStream();
            //myResponseStream.Write(bytes, 0, bytes.Length);

            //HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            //StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            //string retString = myStreamReader.ReadToEnd();

            //myStreamReader.Close();
            //myResponseStream.Close();

            //if (response != null)
            //{
            //    response.Close();
            //}
            //if (request != null)
            //{
            //    request.Abort();
            //}
            string srev = "";
            objsocket.sendsocket(Data);
            Thread.Sleep(300);
            DateTime datestart = DateTime.Now;
            while (true)
            {
                srev = getRecMsg();
                if (!string.IsNullOrEmpty(srev))
                {
                    objsocket.strRecMsg = "";
                    break;
                }
                if (datestart.AddSeconds(3) < DateTime.Now)
                {
                    srev = "-2,获取时间超时！";
                    break;
                }
                Thread.Sleep(100);
            }
            return srev;
        }

        public string connetzhuche()
        {

            string stime = "";
            DateTime date = DateTime.Now;
            //string swybm = m_mainform.stationCode + m_mainform.lineCode + date.ToString("yyyyMMddHHmmssfff");
            stime = string.Format(@"{0}{1}@@@{2}tek", "LJZC", date.ToString("yyyy-MM-dd HH:mm:ss"), m_mainform.lineCode);

            string json = string.Format(@"{0}{1}####", stime, gb2312_xy(stime));
            string sjieguo = Post(m_mainform.surl, json, "");

            string sjiexi = sjjx("LJZC", json, sjieguo);
            //string sjieguo = senddate("LJZC", "");
            return sjiexi;
        }
        public override string start(string sjylsh, string stime, string sycy, string sczy,bool bqz)
        {
            if (!sendobd(sjylsh,bqz))
            {
                return "0";
            }
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = sjylsh;
            value["StationCode"] = m_mainform.stationCode;
            value["SceneCode"] = m_mainform.lineCode;
            value["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            value["Code"] = "start";
            string svalue = value.ToJson();

            //string stime = "";
            //stime = string.Format(@"{0}{1}{2}{3}@@@{4}tek", "HJ04", m_mainform.stationCode, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_mainform.cityCode, svalue);
            //string json = string.Format(@"{0}{1}####", stime, gb2312_xy(stime));
            //string sjieguo = Post(m_mainform.surl, json, "");

            string sjieguo = senddate("HJ04", svalue);
            //m_mainform.baocunriji("HJ04", svalue);
            //m_mainform.baocunriji("HJ04结果", sjieguo);
            if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
            {
                MessageBox.Show("发送检测过程开始时:" + sjieguo);
            }
            bydhh = false;
            string sql = string.Format(@"Select *  from YJHJ03 where  InspectionNum='{0}' ", sjylsh);

            DataTable dt = objdb.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {

                    m_mainform.VLPN = dt.Rows[i]["VLPN"].ToString().Trim();
                    m_mainform.VLPNColor = dt.Rows[i]["VLPNColor"].ToString().Trim();
                    m_mainform.VIN = dt.Rows[i]["VIN"].ToString().Trim();
                    //m_mainform.InspectionOperator = sczy;
                    //m_mainform.InspectionDriver = sycy;


                    m_mainform.InspectionNature = dt.Rows[i]["InspectionNature"].ToString().Trim();
                    //m_mainform.InspectionTimes = dt.Rows[i]["InspectionTimes"].ToString().Trim();
                    //m_mainform.DayAcceptanceNum = dt.Rows[i]["DayAcceptanceNum"].ToString().Trim();

                    bydhh = dt.Rows[i]["FuelType"].ToString().Trim().Contains("O");

                    string scllxbh = dt.Rows[i]["GAVType"].ToString().Trim();
                    string scllx = "轻型";
                    if (scllxbh.Contains("B1") || scllxbh.Contains("H1") || scllxbh.Contains("K1"))//||scllxbh.Contains("H1")||scllxbh.Contains("H1")||
                    {
                        scllx = "重型";
                    }

                    m_mainform.BenchmarkMass = dt.Rows[i]["BenchmarkMass"].ToString().Trim();
                    //    m_mainform.baocunCLXX(m_mainform.VLPN, m_mainform.VLPNColor, dt.Rows[i]["EnginePower"].ToString().Trim(), dt.Rows[i]["EngineRatedSpeed"].ToString().Trim(), m_mainform.BenchmarkMass, scllx);//

                }
            }

            return sjieguo;
        }
        bool stopex(string sjylsh, string jyjg)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = sjylsh;
            value["StationCode"] = m_mainform.stationCode;
            value["SceneCode"] = m_mainform.lineCode;
            value["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            value["Code"] = "stop";
            string svalue = value.ToJson();

            //string stime = "";
            //stime = string.Format(@"{0}{1}{2}{3}@@@{4}tek", "HJ04", m_mainform.stationCode, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_mainform.cityCode, svalue);
            //string json = string.Format(@"{0}####", stime, gb2312_xy(stime));
            //string sjieguo = Post(m_mainform.surl, json, "");

            string sjieguo = senddate("HJ04", svalue);
            //m_mainform.baocunriji("HJ04js", svalue);
            //m_mainform.baocunriji("HJ04js结果", sjieguo);
            return true;
        }

        public override string baocunclexxyj(string slsh)
        {
            string sql = string.Format(@"Select *  from YJHJ03 where  InspectionNum='{0}' ", slsh);

            DataTable dt = objdb.GetTable(sql);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {

                    m_mainform.VLPN = dt.Rows[i]["VLPN"].ToString().Trim();
                    m_mainform.VLPNColor = dt.Rows[i]["VLPNColor"].ToString().Trim();
                    m_mainform.VIN = dt.Rows[i]["VIN"].ToString().Trim();
                    m_mainform.InspectionNature = dt.Rows[i]["InspectionNature"].ToString().Trim();
                    //m_mainform.InspectionTimes = dt.Rows[i]["InspectionTimes"].ToString().Trim();
                    //m_mainform.DayAcceptanceNum = dt.Rows[i]["DayAcceptanceNum"].ToString().Trim();

                    string scllxbh = dt.Rows[i]["GAVType"].ToString().Trim();
                    string scllx = "轻型";
                    if (scllxbh.Contains("B1") || scllxbh.Contains("H1") || scllxbh.Contains("K1"))//||scllxbh.Contains("H1")||scllxbh.Contains("H1")||
                    {
                        scllx = "重型";
                    }

                    m_mainform.BenchmarkMass = dt.Rows[i]["BenchmarkMass"].ToString().Trim();

                    m_mainform.baocunCLXX(m_mainform.VLPN, m_mainform.VLPNColor, dt.Rows[i]["EnginePower"].ToString().Trim(), dt.Rows[i]["EngineRatedSpeed"].ToString().Trim(), m_mainform.BenchmarkMass, scllx,"");//

                }
            }
            return "1";
        }

        public string gb2312_xy(string sneirong)//校验位
        {
            string sjieguo = "";
            Encoding gb2312;

            gb2312 = Encoding.GetEncoding("GB2312");
            byte[] gb = gb2312.GetBytes(sneirong);
            if (gb.Length > 1)
            {
                byte b = 0x00;
                for (int i = 0; i < gb.Length; i++)
                {
                    if (i < 1)
                    {
                        b = (byte)(gb[i] ^ 0x00);
                    }
                    else
                    {
                        b = (byte)(b ^ gb[i]);
                    }
                }
                sjieguo = string.Format("{0:D2}", Convert.ToString(b, 16)); ;

            }
            if (sjieguo.Length < 2)
                sjieguo = "0" + sjieguo;
            return sjieguo;

        }

        public override string senddate(string sID, string svalue)
        {
            string stime = "";
            DateTime date = DateTime.Now;
            string swybm = m_mainform.stationCode + m_mainform.lineCode + date.ToString("yyyyMMddHHmmssfff");
            stime = string.Format(@"{0}{1}{2}{3}@@@{4}tek", sID, m_mainform.stationCode + m_mainform.lineCode, date.ToString("yyyy-MM-dd HH:mm:ss"), swybm, svalue);

            string json = string.Format(@"{0}{1}####", stime, gb2312_xy(stime));
            string sjieguo = Post(m_mainform.surl, json, "");
            Trace.WriteLine(sID + ":" + json);
            Trace.WriteLine(sID + ":" + sjieguo);

            m_mainform.baocunriji(sID, json);
            m_mainform.baocunriji(sID + "返回结果", sjieguo);
            //数据解析
            string sjiexi = sjjx(sID, json, sjieguo);
            //-------------------------------------------------
            //return sjieguo;
            return sjiexi;
        }
        public string sjjx(string sid, string ssend, string sjieguo)
        {
            string srev = "";
            //    ssend="HJ03440601099322019-05-30 12:47:104406010993220190530124710217@@@{\"StationCode\":\"440601099\",\"SceneCode\":\"32\",\"InspectionMethod\":\"A\",\"VLPN\":\"\",\"VLPNColor\":\"\",\"VIN\":\"\",\"StartTime\":\"2019-04-30 00:01:01\",\"EndTime\":\"2019-06-30 00:01:01\"}tek76####";
            //sjieguo = "HJ03440601099322019-05-30 12:47:104406010993220190530124710217@@@1,2019-05-30 12:47:10tek1f####HJ03440601099322019-05-30 12:42:524406010993220190530124710217@@@[{\"HasCCA\":1,\"HasOBD\":\"1\",\"OilSupplyWay\":\"02\",\"IntakeWay\":null,\"EngineRatedSpeed\":1600,\"EnginePower\":3500.0,\"EDSPL\":0.56,\"EngineNum\":\"234234324\",\"Mileage\":null,\"RatedSeats\":4,\"VML\":2500,\"BenchmarkMass\":2100,\"KerbMass\":2000,\"GAVType\":\"K33\",\"InspectionNum\":\"4406010990120190527124921583\",\"StationCode\":\"440601099\",\"SceneCode\":\"32\",\"VLPN\":\"赣A28S20\",\"VLPNColor\":\"01\",\"FuelType\":\"A\",\"VIN\":\"ERWERWERWERWE\",\"Operator\":\"fsslce\",\"AcceptanceDate\":\"2019-05-27T12:49:21.583\",\"InspectionMethod\":\"A\",\"InspectionNature\":\"01\",\"DayAcceptanceNum\":\"0003\"},{\"HasCCA\":1,\"HasOBD\":\"1\",\"OilSupplyWay\":\"02\",\"IntakeWay\":null,\"EngineRatedSpeed\":1600,\"EnginePower\":3500.0,\"EDSPL\":0.56,\"EngineNum\":\"234234324\",\"Mileage\":null,\"RatedSeats\":4,\"VML\":2500,\"BenchmarkMass\":2100,\"KerbMass\":2000,\"GAVType\":\"K33\",\"InspectionNum\":\"4406010990120190527124918666\",\"StationCode\":\"440601099\",\"SceneCode\":\"32\",\"VLPN\":\"赣A28S20\",\"VLPNColor\":\"01\",\"FuelType\":\"A\",\"VIN\":\"ERWERWERWERWE\",\"Operator\":\"fsslce\",\"AcceptanceDate\":\"2019-05-27T12:49:18.667\",\"InspectionMethod\":\"A\",\"InspectionNature\":\"01\",\"DayAcceptanceNum\":\"0002\"}]tek06####";

            //if (ssend.Substring(0, 4) == sjieguo.Substring(0, 4))
            //{
            string[] ssjs = Regex.Split(sjieguo, "####", RegexOptions.IgnoreCase);
            for (int i = ssjs.Length - 1; i >= 0; i--)
            {
                if (ssjs[i].Length > 4 && ssend.Substring(0, 4) == ssjs[i].Substring(0, 4))
                {
                    string[] str = Regex.Split(ssjs[i], "@@@", RegexOptions.IgnoreCase);
                    int istart = ssjs[i].IndexOf("@@@") + 3;
                    int ileng = ssjs[i].IndexOf("tek") - ssjs[i].IndexOf("@@@") - 3;
                    srev = ssjs[i].Substring(istart, ileng);

                    //istart = sjieguo.IndexOf("[") + 1;
                    //ileng = sjieguo.IndexOf("]") - sjieguo.IndexOf("[") - 1;
                    //if (istart > 0)
                    //{
                    //    srev = sjieguo.Substring(istart, ileng);
                    //}

                    return srev;
                }
            }
            //}
            //else
            //{
            //    srev = "-1,解析失败!";
            //}
            return "-1,解析失败!"; ;

        }
        public bool bobdpd = true;
        public override string sendOBDJCJG(string sjylsh)
        {
            return "1";
        }

        public bool sendobd(string sjylsh,bool bqz)
        {

            bobdpd = true;
            string jyksrq = "";
            string jyjsrq = "";
            string jyy = "";
            string jyjg = "1";
            string obdzdyscqy = "";
            string obdzdyxh = "";
            string vin = "";
            string obdyq = "";
            string gzjg = "";
            string tx = "";
            string txbz = "";
            string bj = "";
            string bjbz = "";
            string jxxm = "";
            string jxxmbz = "";
            string odometer = "";
            string odomil = "0";
            string enginecalid = "";
            string enginecvn = "";
            string hclcalid = "";
            string hclcvn = "";
            string calid = "";
            string cvn = "";
            string iupr = "";

            string iuprnmhc = "";                  //01	NMHC 催化器
            string iuprnox = "";                   //02	NOX 催化器
            string iuprnoxxf = "";                 //03	NOX吸附器
            string iuprpm = "";                    //04	颗粒(PM)捕集器
            string iuprfq = "";                    //05	废气传感器
            string iuprerg = "";                   //06	ERG 和 VVT
            string iuprzy = "";                    //07	增压压力
            string iuprch1 = "";                   //08	催化器组1
            string iuprch2 = "";                   //09	催化器组2
            string iuprqcgq1 = "";                 //10	前氧传感器组1
            string iuprqchq2 = "";                 //11	前氧传感器组2
            string iuprhcqg1 = "";                 //12	后氧传感器组1
            string iuprhcqg2 = "";                 //13	后氧传感器组2
            string iuprevag = "";                  //14	EVAP
            string iuprgpf1 = "";                  //16	GPF组1
            string iuprgp2 = "";                   //17	GPF组2
            string iuprerci = "";                  //18	二次空气喷射系统
            string obdtype = "EOBD";                   //19	OBD类型


            int igzmcount = 0;
            int ijxztcount = 0;
            readjcyq();//OBD
            //查询数据内容
            string sfxinche = "";
            string sqlobd;
            string obdjc;
            string gzmnmae = "";
            string unFinifishedItemName = "";
            string sbntxyy = "";
            sqlobd = string.Format(@"select * from YJHJ03 where InspectionNum='{0}'", sjylsh);
            DataTable dtobd = objdb.GetTable(sqlobd);
            m_mainform.sfOBD = false;
            string sCommFailReason = "";
            string sIsCommunicated = "1";
            if (dtobd.Rows.Count > 0)
            {
                obdjc = dtobd.Rows[0]["HasOBD"].ToString().Trim();
                //  sfxinche = dtobd.Rows[0]["InspectionKind"].ToString().Trim();
                if (obdjc.Contains("1"))
                {
                    m_mainform.sfOBD = true;
                }

            }
            if (m_mainform.sfOBD)
            {

                string sql;

                sql = string.Format(@"select * from OBD_JCJG  where jylsh ='{0}'  order by OBD_JCJG_ID desc", sjylsh);// DateTime.Now.AddDays(-30), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                DataTable dt = objdb.GetTable(sql);
                #region 如果检测到OBD数据
                if (dt.Rows.Count > 0)
                {

                    sbntxyy = dt.Rows[0]["time"].ToString().Trim();
                    jyksrq = dt.Rows[0]["OBD_JCJG_date"].ToString().Trim();
                    jyjsrq = dt.Rows[0]["OBD_JCJG_date"].ToString().Trim();

                    jyy = "";//
                    jyjg = "1";
                    obdzdyscqy = m_mainform.OBDqiye;
                    obdzdyxh = m_mainform.OBDname;
                    vin = "";
                    obdyq = "EOBD";
                    gzjg = "1";
                    bj = "1";
                    bjbz = "";

                    for (int i = 0; i < 7; i++)
                    {
                        if (dt.Rows[0][string.Format("OBD_JCJG_GZM{0}", i + 1)].ToString().Trim().Length > 0)
                        {
                            gzjg = "0";
                            bj = "0";
                            igzmcount++;
                            string name = dt.Rows[0][string.Format("OBD_JCJG_GZM{0}", i + 1)].ToString().Trim();
                            gzmnmae += name + ";";
                            if (bjbz.Length < 1)
                            {
                                bjbz = makeOBD2(dt.Rows[0][string.Format("OBD_JCJG_GZM{0}", i + 1)].ToString().Trim());
                            }
                            else
                            {
                                bjbz = bjbz + "|" + makeOBD2(dt.Rows[0][string.Format("OBD_JCJG_GZM{0}", i + 1)].ToString().Trim());
                            }
                        }

                    }

                    tx = "1";
                    txbz = "";


                    jxxm = "1";
                    jxxmbz = "";

                    for (int i = 0; i < 10; i++)
                    {
                        if (dt.Rows[0][string.Format("OBD_JCJG_JXZT{0}", i + 1)].ToString().Trim().Contains("未完成"))
                        {
                            jxxm = "0";
                            string sjxztwwc = dt.Rows[0][string.Format("OBD_JCJG_JXZT{0}", i + 1)].ToString().Trim();
                            unFinifishedItemName += sjxztwwc + ";";
                            if (sjxztwwc.Contains("SCR"))
                            {
                                jxxmbz += "01|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("POC"))
                            {
                                jxxmbz += "02|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("DOC"))
                            {
                                jxxmbz += "03|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("DPF"))
                            {
                                jxxmbz += "04|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("EGR"))
                            {
                                jxxmbz += "05|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("催化器"))
                            {
                                jxxmbz += "06|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("氧传感器加热器"))
                            {
                                jxxmbz += "08|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("氧传感器"))
                            {
                                jxxmbz += "07|";
                                ijxztcount++;
                            }
                            else if (sjxztwwc.Contains("可变气门VVT"))
                            {
                                jxxmbz += "09|";
                                ijxztcount++;
                            }
                            //if (bjbz.Length < 1)
                            //{
                            //    jxxmbz = dt.Rows[0][string.Format("OBD_JCJG_JXZT{0}", i + 1)].ToString().Trim();
                            //}
                            //else
                            //{
                            //    jxxmbz = bjbz + dt.Rows[0][string.Format("OBD_JCJG_JXZT{0}", i + 1)].ToString().Trim();
                            //}
                        }

                    }
                    jxxmbz = jxxmbz.TrimEnd('|');
                    for (int i = 0; i < 12; i++)
                    {
                        if (dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim().Contains("里程表"))
                        {

                            odometer = makeOBD(dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim());

                        }
                        if (dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim().Contains("点亮后的行驶距离"))
                        {

                            odomil = makeOBD(dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim()).Trim();
                            float fodocs = 0;
                            if (!float.TryParse(odomil, out fodocs))
                            {
                                odomil = "0";
                            }

                        }

                        if (dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim().Contains("车辆OBD类型"))
                        {
                            obdtype = makeOBD(dt.Rows[0][string.Format("OBD_JCJG_SJL{0}", i + 1)].ToString().Trim());
                        }
                    }

                    enginecalid = makeOBD(dt.Rows[0]["OBD_JCJG_CLXX1"].ToString().Trim());
                    enginecvn = makeOBD(dt.Rows[0]["OBD_JCJG_CLXX2"].ToString().Trim());
                    hclcalid = "";
                    hclcvn = "";
                    calid = "";
                    cvn = "";
                    iupr = "";
                    for (int i = 0; i < 34; i++)
                    {
                        if (dt.Rows[0][string.Format("OBD_JCJG_IUPR{0}", i + 1)].ToString().Trim().Length > 0)
                        {
                            if (dt.Rows[0][string.Format("OBD_JCJG_IUPR{0}", i + 1)].ToString().Trim().Contains("NMHC"))
                            {
                                iuprnmhc = "01";//makeOBD(dt.Rows[0][string.Format("OBD_JCJG_IUPR{0}", i + 1)].ToString().Trim());
                            }
                            else if (dt.Rows[0][string.Format("OBD_JCJG_IUPR{0}", i + 1)].ToString().Trim().Contains("NOX"))
                            {
                                iuprnox = "02";//makeOBD(dt.Rows[0][string.Format("OBD_JCJG_IUPR{0}", i + 1)].ToString().Trim());
                            }

                            //格式化iupr
                        }

                    }
                    if (ijxztcount >= 2 || igzmcount > 0)
                    {
                        jyjg = "0";
                        bobdpd = false;
                    }
                    ///
                    //if (sbntxyy.Contains("找不到") && sobdsfkq == "否")
                    //{
                    //    sCommFailReason = "";
                    //    sIsCommunicated = "1";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "1";
                    //    bobdpd = true;
                    //    odomil = "0";
                    //}
                    //else if (sbntxyy.Contains("找不到"))
                    //{
                    //    sCommFailReason = "02";
                    //    sIsCommunicated = "0";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "0";
                    //    bobdpd = false;
                    //    odomil = "0";
                    //}
                    //else if (sbntxyy.Contains("接口损坏") && sobdsfkq == "否")
                    //{
                    //    sCommFailReason = "";
                    //    sIsCommunicated = "1";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "1";
                    //    bobdpd = true;
                    //    odomil = "0";
                    //}
                    //else if (sbntxyy.Contains("接口损坏"))
                    //{
                    //    sCommFailReason = "01";
                    //    sIsCommunicated = "0";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "0";
                    //    bobdpd = false;
                    //    odomil = "0";
                    //}
                    //else if (sbntxyy.Contains("不能通讯") && sobdsfkq == "否")
                    //{
                    //    sCommFailReason = "";
                    //    sIsCommunicated = "1";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "1";
                    //    bobdpd = true;
                    //    odomil = "0";

                    //}
                    //else if (sbntxyy.Contains("不能通讯"))
                    //{
                    //    sCommFailReason = "03";
                    //    sIsCommunicated = "0";
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "0";
                    //    bobdpd = false;
                    //    odomil = "0";
                    //}
                    //else if (sobdsfkq == "否" && jyjg != "1")
                    //{
                    //    igzmcount = 0;
                    //    ijxztcount = 0;
                    //    jxxmbz = "";
                    //    bjbz = "";
                    //    jyjg = "1";
                    //    bobdpd = true;
                    //    odomil = "0";
                    //}
                }
                #endregion
                //else if (sobdsfkq == "否")
                //{
                //    igzmcount = 0;
                //    ijxztcount = 0;
                //    jxxmbz = "";
                //    bjbz = "";
                //    jyjg = "1";
                //    bobdpd = true;
                //    odomil = "0";
                //}
                else
                {
                    MessageBox.Show("无法找到OBD数据，请先上传OBD数据再开始检测");
                    return false;
                } 
                //if (sobdsfkq == "否")
                //{//wwt20200524
                if (bqz)
                {
                    igzmcount = 0;
                    ijxztcount = 0;
                    jxxmbz = "";
                    bjbz = "";
                    jyjg = "1";
                    bobdpd = true;
                    odomil = "0";
                }
                //}
                if (jyjg.Contains("0"))
                {
                    string sbhg = string.Format("不合格项目：故障码：{0}\r\n未就绪项目:{1}\r\n是否继续检测？", gzmnmae, unFinifishedItemName);
                    if (MessageBox.Show(sbhg, "提示", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return false;
                    }
                }


                /////
                sql = string.Format("select * from YJHJ03 where InspectionNum='{0}'", sjylsh);
                DataTable dthj03 = objdb.GetTable(sql);
                if (dthj03.Rows.Count > 0)
                {
                    var result = new 云景model.HJ05()
                    {

                        InspectionNum = sjylsh,
                        StationCode = m_mainform.stationCode,
                        VIN = dthj03.Rows[0]["VIN"].ToString().Trim(),
                        VLPN = dthj03.Rows[0]["VLPN"].ToString().Trim(),
                        VLPNColor = dthj03.Rows[0]["VLPNColor"].ToString().Trim(),
                        OBDInspectStartTime = DateTime.Now.AddMinutes(-5).ToString("yyyy-MM-dd HH:mm:ss"),
                        OBDInspectEndTime = DateTime.Now.AddMinutes(-4).ToString("yyyy-MM-dd HH:mm:ss"),
                        ODO = odomil.Length>1?odomil:"0",
                        FaultIndicatorLighten = "1",
                        IsCommunicated = sIsCommunicated,
                        CommFailReason = sCommFailReason,
                        FaultIndicator = "1",
                        IsHaveFaultCode = igzmcount > 0 ? "1" : "0",
                        FaultInfo = bjbz,
                        UnDoneReadyStatus = ijxztcount > 1 ? "1" : "0",
                        UnFinifishedItem = jxxmbz,
                        ECU_CALID = enginecalid,
                        ECU_CVN = enginecvn,
                        ACU_CALID = "",
                        ACU_CVN = "",
                        OCU_CALID = "",
                        OCU_CVN = "",
                        StatusCoherence = "1",
                        CheckPerson = m_mainform.InspectionOperator,
                        OBDInspectResult = jyjg,
                        IsNeedReCheck = jyjg == "0" ? "1" : "0",
                        ReCheckContent = "",
                        InspectionNature = dthj03.Rows[0]["InspectionNature"].ToString().Trim(),
                        InspectionTimes = dthj03.Rows[0]["InspectionNature"].ToString().Trim(),
                        DeviceMANU = m_mainform.OBDqiye,
                        DeviceType = m_mainform.OBDname,
                        OBDType = obdtype.Length>1?obdtype:"EOBD",
                        RemoteCommunicated = "1"
                    };
                    string svalue = JsonConvert.SerializeObject(result);


                    var resultiru = new 云景model.HJ40()
                    {
                        InspectionNum = sjylsh,
                        StationCode = m_mainform.stationCode,
                        VIN = dthj03.Rows[0]["VIN"].ToString().Trim(),
                        VLPN = dthj03.Rows[0]["VLPN"].ToString().Trim(),
                        VLPNColor = dthj03.Rows[0]["VLPNColor"].ToString().Trim(),
                        MonitorName = "01",
                        MonitorFinishTimes = "25",
                        MonitorFitTimes = "20",
                        IUPR = "35"
                    };
                    string svalueobd = JsonConvert.SerializeObject(resultiru);

                    string sjieguoobd = senddate("HJ40", svalueobd);
                    //m_mainform.baocunriji("HJ40", svalueobd);
                    //m_mainform.baocunriji("HJ40结果", sjieguoobd);
                    if (sjieguoobd.Substring(0, sjieguoobd.IndexOf(",")) != "1")
                    {
                        //MessageBox.Show("发送OBDIRY检测结果时:" + sjieguoobd);//大修厂经常显示出现解析失败
                        //return false;
                    }

                    //检测结果
                    string sjieguo = senddate("HJ05", svalue);
                    if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
                    {
                        MessageBox.Show("发送OBD检测结果时:" + sjieguo);
                        return true;
                    }
                }
                else
                {
                    MessageBox.Show("发送OBD时查询不到车辆信息");
                    return false;
                }
            }
            return true;
        }
        public string makeOBD(string obd)
        {
            string shuoming = "";
            string shuoming2 = string.Empty;
            string[] a = Regex.Split(obd, ",", RegexOptions.IgnoreCase);
            //for (int i = 0; i < a.Length; i++)
            if (a.Length > 1)
            {
                shuoming = a[0];
                shuoming2 = a[1];
            }

            return shuoming2;
        }

        public string makeOBD2(string obd)
        {
            string shuoming = "";
            string shuoming2 = string.Empty;
            string[] a = Regex.Split(obd, ",", RegexOptions.IgnoreCase);
            for (int i = 0; i < a.Length; i++)
            {
                shuoming = a[0];
                shuoming2 = a[1];
            }

            return shuoming;
        }



        public override string sendOBDGCSJ(string sjylsh, string stime, int simslsh)
        {

            //查询数据内容
            string sql;

            //sql = string.Format(@"select * from OBD_GCSJ  where jylsh ='{0}'  order by OBDGCSJ_ID desc", sjylsh);// DateTime.Now.AddDays(-30), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            //DataTable dt = objdb.GetTable(sql);
            //if (dt.Rows.Count > 0)
            {

                //jyksrq = dt.Rows[0]["OBD_JCJG_date"].ToString().Trim();
                //jyjsrq = dt.Rows[0]["OBD_JCJG_date"].ToString().Trim();

                float fshuzhi = 0;
                var result = new 云景model.HJ06()
                {
                    InspectionNum = sjylsh,
                    StationCode = m_mainform.stationCode,
                    ProcessTime = stime,
                    Second_NO = string.Format(@"{0}", simslsh),
                    Flow_Speed = m_mainform.OBD_cs,// dt.Rows[0]["cs"].ToString().Trim(),//逐秒车速
                    Flow_RotateSpeed = m_mainform.OBD_fdjzs,// dt.Rows[0]["fdjzs"].ToString().Trim(),//逐秒发动机转速
                    Flow_AirInput = m_mainform.OBD_jql,// dt.Rows[0]["jql"].ToString().Trim(),//逐秒进气量
                    Flow_ThrottlePosition = m_mainform.OBD_ymkd,// dt.Rows[0]["ymkd"].ToString().Trim(),//逐秒油门开度
                    Flow_OutputPower = m_mainform.OBD_scgl,// dt.Rows[0]["scgl"].ToString().Trim(),//逐秒发动机输出功率
                    Flow_BoostPressure = m_mainform.OBD_zyyl,// dt.Rows[0]["zyyl"].ToString().Trim(),//逐秒增压压力
                    Flow_OilConsume = m_mainform.OBD_hyl,// dt.Rows[0]["hyl"].ToString().Trim(),//逐秒耗油量
                    Flow_NOX = m_mainform.OBD_no,// dt.Rows[0]["no"].ToString().Trim(),//逐秒氮氧传感器浓度
                    Flow_UreaInject = m_mainform.OBD_nsbsl,// dt.Rows[0]["nsbsl"].ToString().Trim(),//逐秒尿素喷射量
                    Flow_ExhaustTmp = m_mainform.OBD_pqwd,// dt.Rows[0]["pqwd"].ToString().Trim(),//逐秒排气温度
                    Flow_DPFPressure = m_mainform.OBD_klbjqyc,// dt.Rows[0]["klbjqyc"].ToString().Trim(),//逐秒颗粒捕集器压差
                    Flow_EGRPostion = m_mainform.OBD_egrkd,// dt.Rows[0]["egrkd"].ToString().Trim(),//逐秒EGR开度
                    Flow_FuelInjectPressure = m_mainform.OBD_rypsyl,// dt.Rows[0]["rypsyl"].ToString().Trim(),//逐秒燃油喷射压力
                    Flow_ThrottleValue = m_mainform.OBD_jqmkd,// dt.Rows[0]["jqmkd"].ToString().Trim(),//逐秒节气门绝对开度
                    Flow_CLV = m_mainform.OBD_fh,// dt.Rows[0]["fh"].ToString().Trim(),//逐秒计算负荷值
                    Flow_PreOSS = m_mainform.OBD_qycgqxh,// dt.Rows[0]["no"].ToString().Trim(),//逐秒前氧传感器信号
                    Flow_Lamda = m_mainform.OBD_glkqxs,// string.Format(@"{0}", m_mainform.objfqy.m_fLamda.ToString("0.00")),//逐秒过量空气系数（入)
                    Flow_IntakePressure = m_mainform.OBD_jqyl//dt.Rows[0]["jqyl"].ToString().Trim()//逐秒进气压力
                };
                string svalue = JsonConvert.SerializeObject(result);

                string sjieguo = senddate("HJ06", svalue);
                //m_mainform.baocunriji("HJ06", svalue);
                //m_mainform.baocunriji("HJ06结果", sjieguo);

                if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
                {
                    return "0";
                }
                else
                {
                    return "1";
                }

                ///
            }
            //else
            //{
            //    return "1";
            //}

        }


        public override void gettime()//同步时间
        {

            //string sendStr = string.Format("LJZC{0}@@@02tek", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            //string json = string.Format(@"{0}{1}####", sendStr, gb2312_xy(sendStr));
            //string sjieguo2 = Post(m_mainform.surl, json, "");
            //string sjieguo = senddate("HJ26", "");
            //return;



            //objsocket.connect("120.236.164.111", 5021);

            //string sendStr = string.Format("LJZC{0}@@@{1}tek", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_mainform.lineCode);
            //string json = string.Format(@"{0}{1}####", sendStr, gb2312_xy(sendStr));
            //string str = string.Format("LJZC{0}@@@01tek", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            //string sjieguo2 = Post("", json, "");
            string sjieguo = senddate("HJ26", "");

        }
        //
        public class RootObject
        {
            public string InspectionNum { get; set; }
            public string StationCode { get; set; }
            public string SceneCode { get; set; }
            public string VLPN { get; set; }
            public string VLPNColor { get; set; }
            public string VIN { get; set; }
            public string FuelType { get; set; }
            public string GAVType { get; set; }
            public string KerbMass { get; set; }
            public string BenchmarkMass { get; set; }
            public string VML { get; set; }
            public string RatedSeats { get; set; }
            public string Mileage { get; set; }
            public string EngineNum { get; set; }
            public string IUETYPE { get; set; }
            public string EDSPL { get; set; }
            public string EnginePower { get; set; }
            public string EngineRatedSpeed { get; set; }
            public string IntakeWay { get; set; }
            public string OilSupplyWay { get; set; }
            public string HasCCA { get; set; }
            public string Operator { get; set; }
            public string AcceptanceDate { get; set; }
            public string InspectionMethod { get; set; }
            public string InspectionNature { get; set; }
            public string DayAcceptanceNum { get; set; }
            public string HasOBD { get; set; }

        }


        public override void insertjcwc(string slsh)//检测完成标志
        {
            string sqlxzxx = string.Format(@"update YJHJ03 set  
                                                JCWCEX='是'
                                                 where  InspectionNum='{0}' ",
                                                slsh);

            m_mainform.objbass.objdb.InsertDB(sqlxzxx);

        }


        public override void getstandxz(string slsh)//获取限值
        {
            string sql;

            sql = string.Format(@"Select *  from YJstand ");

            DataTable dt = objdb.GetTable(sql);
            if (dt.Rows.Count > 0)
            {

                float.TryParse(dt.Rows[0]["HCEL5025"].ToString().Trim(), out m_mainform.HCEL5025);
                float.TryParse(dt.Rows[0]["COEL5025"].ToString().Trim(), out m_mainform.COEL5025);
                float.TryParse(dt.Rows[0]["NOEL5025"].ToString().Trim(), out m_mainform.NOEL5025);
                float.TryParse(dt.Rows[0]["HCEL2540"].ToString().Trim(), out m_mainform.HCEL2540);
                float.TryParse(dt.Rows[0]["COEL2540"].ToString().Trim(), out m_mainform.COEL2540);
                float.TryParse(dt.Rows[0]["NOEL2540"].ToString().Trim(), out m_mainform.NOEL2540);

                float.TryParse(dt.Rows[0]["LICOL"].ToString().Trim(), out m_mainform.LICOL);
                float.TryParse(dt.Rows[0]["LIHCL"].ToString().Trim(), out m_mainform.LIHCL);
                float.TryParse(dt.Rows[0]["HICOL"].ToString().Trim(), out m_mainform.HICOL);
                float.TryParse(dt.Rows[0]["HIHCL"].ToString().Trim(), out m_mainform.HIHCL);

                //float.TryParse(dt.Rows[0]["TypeApprovalLimits"].ToString().Trim(), out m_mainform.TypeApprovalLimits);
                //float.TryParse(dt.Rows[0]["InspectionLimits"].ToString().Trim(), out m_mainform.InspectionLimits);

                float.TryParse(dt.Rows[0]["KEL"].ToString().Trim(), out m_mainform.TypeApprovalLimits);
                float.TryParse(dt.Rows[0]["NOX"].ToString().Trim(), out m_mainform.noxlimit);
                float.TryParse(dt.Rows[0]["KELex"].ToString().Trim(), out m_mainform.InspectionLimits);

                //  float.TryParse(dt.Rows[i]["STD_NOX"].ToString().Trim(), out noxlimit);

            }
            else
            {

            }
        }


        bool bdyc = true;
        public override DataTable getjilu(string shphm, string sdatestart, string sdateend, bool bbz)//获取登录车辆上线
        {
            if (!bbz)
            {
                //SceneCode ="", 
                var result = new ReturnObject()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    InspectionMethod = "A",
                    VLPN = "",
                    VLPNColor = "",
                    VIN = "",
                    StartTime = sdatestart,
                    EndTime = sdateend
                };
                //VLPN = "测YUN52",
                //VLPNColor = "01",
                //VIN = m_mainform.lineCode,
                string[] sInspectionMethods = new string[] { "B", "A", "G", "F" };
                if (sjcxlb.Contains("汽"))
                {
                    sInspectionMethods = new string[] { "A", "B" };
                }
                else if (sjcxlb.Contains("柴"))
                {
                    sInspectionMethods = new string[] { "G", "F" };
                }
                else
                {
                    sInspectionMethods = new string[] { "A", "B", "G", "F" };
                }

                //result.InspectionMethod = sInspectionMethods[i];
                result.InspectionMethod = "";
                string svalue = JsonConvert.SerializeObject(result);
                string sjieguo = senddate("HJ03", svalue);
                if (sjieguo.Substring(0, sjieguo.IndexOf(',')) == "1" || sjieguo.Substring(0, sjieguo.IndexOf(',')) == "0")
                {

                }
                else
                {
                    //int istart = sjieguo.IndexOf("[") + 1;
                    //int ileng = sjieguo.IndexOf("]") - sjieguo.IndexOf("[") - 1;
                    //if (istart > 0)
                    {
                        //string srev = sjieguo.Substring(istart, ileng);
                        //updateclxx(sjieguo, sInspectionMethods[i]);
                        updateclxx(sjieguo, "");
                    }
                }
                for (int i = 0; i < sInspectionMethods.Length; i++)
                {
                    if (bdyc)
                    {
                        string sjieguoex = senddate("HJ01", sInspectionMethods[i]);
                        updatestand(sjieguoex, sInspectionMethods[i]);
                    }
                    //Thread.Sleep(2000);
                }
                bdyc = false;
            }
            DataTable dtref = new DataTable();
            dtref.Columns.Add("DETECT_ID");
            dtref.Columns.Add("PLATE_ID");
            dtref.Columns.Add("PCLASS_ID");
            dtref.Columns.Add("jcff");
            dtref.Columns.Add("OBD");
            dtref.Columns.Add("jccs");
            dtref.Columns.Add("zt");

            // string ssql = string.Format("select * from YJHJ03 where VLPN like '%{0}%' and AcceptanceDate>='{1}' and AcceptanceDate<='{2}' and SceneCode='{3}'", shphm, sdatestart, sdateend, m_mainform.lineCode);
            string ssql = string.Format("select * from YJHJ03 where VLPN like '%{0}%' and AcceptanceDate>='{1}' and AcceptanceDate<='{2}'", shphm, sdatestart, sdateend);
            //dt = m_mainform.GetTable(ssql);

            DataTable dt = objdb.GetTable(ssql);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (!(dt.Rows[i]["JCWCEX"].ToString().Trim().Contains("是")) || bbz)
                    {
                        DataRow dr = dtref.NewRow();
                        dr[0] = dt.Rows[i]["InspectionNum"].ToString().Trim();    //填充第一列的数据 
                        dr[1] = string.Format("{0}", dt.Rows[i]["VLPN"].ToString().Trim());    //填充第一列的数据 
                        dr[2] = string.Format("{0}", dt.Rows[i]["VLPNColor"].ToString().Trim());    //填充第一列的数据 

                        int icount = 0;
                        int.TryParse(dt.Rows[i]["InspectionNature"].ToString().Trim(), out icount);
                        string InspectionMethod = dt.Rows[i]["InspectionMethod"].ToString().Trim();
                        string sfujianqingk = "";
                        if (dt.Rows[i]["InspectionNature"].ToString().Trim() == "01")
                        {
                            sfujianqingk = "(初检)";
                        }
                        else if (dt.Rows[i]["InspectionNature"].ToString().Trim() == "02")
                        {
                            sfujianqingk = "(复检)";
                        }
                        else if (dt.Rows[i]["InspectionNature"].ToString().Trim() == "03")
                        {
                            sfujianqingk = "(多检)";
                        }
                        if (InspectionMethod.Contains("A"))
                        {
                            dr[3] = string.Format("双怠速法");
                        }
                        else if (InspectionMethod.Contains("F"))
                        {
                            dr[3] = string.Format("自由加速法");
                        }
                        else if (InspectionMethod.Contains("B"))
                        {
                            dr[3] = string.Format("ASM工况法");
                        }
                        else if (InspectionMethod.Contains("G"))
                        {
                            dr[3] = string.Format("加载减速法");
                        }
                        dr[4] = dt.Rows[i]["HasOBD"].ToString().Trim().Contains("1") ? "是" : "否";
                        dr[5] = string.Format("{0}", sfujianqingk);
                        dr[6] = dt.Rows[i]["JCWCEX"].ToString().Trim().Contains("是") ? "已完成" : "未完成";
                        dtref.Rows.Add(dr);

                    }


                }
            }
            //string stime = "";
            //"StationCode":"440605001","SceneCode":"01',"InspectionMethod":"A","VLPN":"桂A00001","VLPNColor":"01",'VIN’’:””,” EndTime’’:”2019-01-01 10:00:00”, ” StartTime”:” 2019-01-0210:00:00” }tek07####
            //stime = string.Format(@"{0}{1}{2}{3}@@@tek", "HJ03", m_mainform.stationCode, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), m_mainform.cityCode);
            //string json = string.Format(@"{0}{1}####", stime, gb2312_xy(stime));
            //string sjieguo = Post(m_mainform.surl, json, "");


            return dtref;
        }
        public string updateclxx(string json, string InspectionMethod)
        {
            //string[] jsons = json.Split(',');
            //for (int i = 0; i < jsons.Length; i++)
            //{
            //    if (string.IsNullOrEmpty(jsons[i]))
            //    {
            //        continue;
            //    }
            JArray jlist = JArray.Parse(json);
            foreach (var item in jlist)
            {
                云景model.HJ03 yjhj03 = new 云景model.HJ03();
                yjhj03.InspectionNum = item["InspectionNum"].ToString().Trim();
                yjhj03.StationCode = item["StationCode"].ToString().Trim();
                yjhj03.SceneCode = item["SceneCode"].ToString().Trim();
                yjhj03.VLPN = item["VLPN"].ToString().Trim();
                yjhj03.VLPNColor = item["VLPNColor"].ToString().Trim();
                yjhj03.VIN = item["VIN"].ToString().Trim();
                yjhj03.FuelType = item["FuelType"].ToString().Trim();
                yjhj03.GAVType = item["GAVType"].ToString().Trim();
                yjhj03.KerbMass = item["KerbMass"].ToString().Trim();
                yjhj03.BenchmarkMass = item["BenchmarkMass"].ToString().Trim();
                yjhj03.VML = item["VML"].ToString().Trim();
                yjhj03.RatedSeats = item["RatedSeats"].ToString().Trim();
                yjhj03.Mileage = item["Mileage"].ToString().Trim();
                yjhj03.EngineNum = item["EngineNum"].ToString().Trim();
                //yjhj03.IUETYPE = item["IUETYPE"].ToString().Trim();
                yjhj03.EDSPL = item["EDSPL"].ToString().Trim();
                yjhj03.EnginePower = item["EnginePower"].ToString().Trim();
                yjhj03.EngineRatedSpeed = item["EngineRatedSpeed"].ToString().Trim();
                yjhj03.IntakeWay = item["IntakeWay"].ToString().Trim();
                yjhj03.OilSupplyWay = item["OilSupplyWay"].ToString().Trim();
                yjhj03.HasCCA = item["HasCCA"].ToString().Trim();
                yjhj03.Operator = item["Operator"].ToString().Trim();
                yjhj03.AcceptanceDate = item["AcceptanceDate"].ToString().Trim();
                yjhj03.InspectionMethod = item["InspectionMethod"].ToString().Trim();
                yjhj03.InspectionNature = item["InspectionNature"].ToString().Trim();
                yjhj03.DayAcceptanceNum = item["DayAcceptanceNum"].ToString().Trim();
                yjhj03.HasOBD = item["HasOBD"].ToString().Trim();

                string ssql = string.Format("select * from YJHJ03 where InspectionNum='{0}'", yjhj03.InspectionNum);
                DataTable dt = objdb.GetTable(ssql);
                if (dt.Rows.Count < 1)
                {
                    ssql = string.Format(@"insert into YJHJ03 (       InspectionNum      ,StationCode      ,SceneCode      
,VLPN      ,VLPNColor      ,VIN      ,FuelType
      ,GAVType
      ,KerbMass
      ,BenchmarkMass
      ,VML
      ,RatedSeats
      ,Mileage
      ,EngineNum
      ,IUETYPE
      ,EDSPL
      ,EnginePower
      ,EngineRatedSpeed
      ,IntakeWay
      ,OilSupplyWay
      ,HasCCA
      ,Operator
      ,AcceptanceDate
      ,InspectionMethod
      ,InspectionNature
      ,DayAcceptanceNum
      ,HasOBD
) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',
'{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}')",
    yjhj03.InspectionNum,
    yjhj03.StationCode,
    yjhj03.SceneCode,
    yjhj03.VLPN,
    yjhj03.VLPNColor,
    yjhj03.VIN,
    yjhj03.FuelType,
    yjhj03.GAVType,
    yjhj03.KerbMass,
    yjhj03.BenchmarkMass,
    yjhj03.VML,
    yjhj03.RatedSeats,
    yjhj03.Mileage,
    yjhj03.EngineNum,
    yjhj03.IUETYPE,
    yjhj03.EDSPL,
    yjhj03.EnginePower,
    yjhj03.EngineRatedSpeed,
    yjhj03.IntakeWay,
    yjhj03.OilSupplyWay,
    yjhj03.HasCCA,
    yjhj03.Operator,
   DateTime.Parse(yjhj03.AcceptanceDate),
    yjhj03.InspectionMethod,
    yjhj03.InspectionNature,
    yjhj03.DayAcceptanceNum,
    yjhj03.HasOBD);
                    m_mainform.objbass.objdb.InsertDB(ssql);


                    //手机APP表
                    string cllx = "01";
                    if (yjhj03.GAVType.Contains("K") || yjhj03.GAVType.Contains("H2"))
                    {
                        cllx = "02";
                    }
                    string sqlAPPs = string.Format("select * from Detects_SJE where PLATE_ID='{0}'and PCLASS_ID='{1}'", yjhj03.VLPN, cllx);
                    DataTable dtapp = objdb.GetTable(sqlAPPs);
                    if (dtapp.Rows.Count < 1)
                    {
                        sqlAPPs = string.Format("insert into Detects_SJE (PLATE_ID,PCLASS_ID,ITERAT ,LOGINDATE,ASM_JYLSH) values ('{0}','{1}','{2}','{3}','{4}')", yjhj03.VLPN, cllx, yjhj03.InspectionNature, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), yjhj03.InspectionNum);
                        m_mainform.objbass.objdb.InsertDB(sqlAPPs);

                    }
                    else
                    {
                        sqlAPPs = string.Format("update Detects_SJE set ITERAT='{0}',ASM_JYLSH='{1}' where PLATE_ID='{2}'and PCLASS_ID='{3}' ", yjhj03.InspectionNature, yjhj03.InspectionNum, yjhj03.VLPN, cllx);
                        m_mainform.objbass.objdb.InsertDB(sqlAPPs);
                    }
                }
                else //if (dt.Rows[0]["InspectionNature"].ToString().Trim() != yjhj03.InspectionNature)
                {
                    ssql = string.Format("update YJHJ03 set InspectionNature='{0}' where InspectionNum='{1}'", yjhj03.InspectionNature, yjhj03.InspectionNum);
                    m_mainform.objbass.objdb.InsertDB(ssql);

                    //手机APP表
                    string cllx = "01";
                    if (yjhj03.GAVType.Contains("K") || yjhj03.GAVType.Contains("H2"))
                    {
                        cllx = "02";
                    }

                    string sqlAPPs = string.Format("select * from Detects_SJE where PLATE_ID='{0}'and PCLASS_ID='{1}'", yjhj03.VLPN, cllx);
                    DataTable dtapp = objdb.GetTable(sqlAPPs);
                    if (dtapp.Rows.Count < 1)
                    {
                        sqlAPPs = string.Format("insert into Detects_SJE (PLATE_ID,PCLASS_ID,ITERAT ,LOGINDATE,ASM_JYLSH) values ('{0}','{1}','{2}','{3}','{4}')", yjhj03.VLPN, cllx, yjhj03.InspectionNature, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), yjhj03.InspectionNum);
                        m_mainform.objbass.objdb.InsertDB(sqlAPPs);
                    }
                    else
                    {

                        sqlAPPs = string.Format("update Detects_SJE set ITERAT='{0}',ASM_JYLSH='{1}' where PLATE_ID='{2}'and PCLASS_ID='{3}' ", yjhj03.InspectionNature, yjhj03.InspectionNum, yjhj03.VLPN, cllx);
                        m_mainform.objbass.objdb.InsertDB(sqlAPPs);
                    }

                }
                //}
            }
            return "";
        }

        public string updatestand(string json, string InspectionMethod)
        {
            //HJ01440601099322019-05-30 15:41:094406010993220190530154109407@@@1,2019-05-30 15:41:09tek13####HJ01440601099322019-05-30 15:41:094406010993220190530154109407@@@
            //{"LimitType":"a","LICOL":0.6,"LIHCL":80,"HICOL":0.3,"HIHCL":50}
            //tek12####
            string sql = "select * from YJstand";
            if (objdb.GetTable(sql).Rows.Count < 1)
            {
                string ssql = string.Format("insert into YJstand (LimitType) values ('a')");
                m_mainform.objbass.objdb.InsertDB(ssql);
            }
            try
            {
                if (InspectionMethod == "A")
                {
                    云景model.HJ01 objhj01 = JsonConvert.DeserializeObject<云景model.HJ01>(json);
                    string ssql = string.Format("update YJstand set LICOL={0},LIHCL={1},HICOL={2},HIHCL={3}", objhj01.LICOL, objhj01.LIHCL, objhj01.HICOL, objhj01.HIHCL);
                    m_mainform.objbass.objdb.InsertDB(ssql);
                }
                else if (InspectionMethod == "B")
                {
                    云景model.HJ01 objhj01 = JsonConvert.DeserializeObject<云景model.HJ01>(json);
                    string ssql = string.Format("update YJstand set COEL5025={0},HCEL5025={1},NOEL5025={2},COEL2540={3},HCEL2540={4},NOEL2540={5}",
          objhj01.COEL5025
          , objhj01.HCEL5025
          , objhj01.NOEL5025
          , objhj01.COEL2540
          , objhj01.HCEL2540
          , objhj01.NOEL2540);
                    m_mainform.objbass.objdb.InsertDB(ssql);

                }
                else if (InspectionMethod == "G")
                {
                    云景model.HJ01 objhj01 = JsonConvert.DeserializeObject<云景model.HJ01>(json);
                    string ssql = string.Format("update YJstand set KEL={0},OPACITYEL={1},NOX={2}"
          , objhj01.KEL
          , objhj01.OPACITYEL
          , string.IsNullOrEmpty(objhj01.NOX) ? "1500" : objhj01.NOX);
                    m_mainform.objbass.objdb.InsertDB(ssql);

                }
                else if (InspectionMethod == "F")
                {
                    云景model.HJ01 objhj01 = JsonConvert.DeserializeObject<云景model.HJ01>(json);
                    string ssql = string.Format("update YJstand set KELex={0},OPACITYELex={1}"
          , objhj01.KEL
          , objhj01.OPACITYEL);
                    m_mainform.objbass.objdb.InsertDB(ssql);

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return "";
        }
        public string getRecMsg()
        {
            string sRecMsg = objsocket.strRecMsg;
            //objsocket.strRecMsg = "";
            return sRecMsg;
        }

        public string updateljh()
        {
            string ssql = string.Format("select * from yjclljh where riqi='{0}'", DateTime.Now.ToString("yyyy-MM-dd"));
            DataTable dtlj = objdb.GetTable(ssql);
            if (dtlj.Rows.Count > 0)
            {
                m_mainform.IUTID = dtlj.Rows[0]["ljh"].ToString().Trim();
                ssql = string.Format("update yjclljh set ljh=ljh+1 where riqi='{0}'", DateTime.Now.ToString("yyyy-MM-dd"));

            }
            else
            {
                m_mainform.IUTID = "1";
                ssql = string.Format("insert into yjclljh (riqi,ljh) values ('{0}',2)", DateTime.Now.ToString("yyyy-MM-dd"));

            }
            m_mainform.objbass.objdb.InsertDB(ssql);
            return "";
        }
        public override string sjuploadASM(string businessId, model.ASM.ASMsj objasmsj, model.ASM.ASMgcsj objasmgcsj, model.ASM.ASMobdgcsj objasmobd, int ics)
        {
            updateljh();//刷新累积号

            string timeEnd = DateTime.Now.ToLocalTime().ToString();
            bool bgood = false;
            if ((!objasmsj.b2540 && (objasmsj.iHC25 > m_mainform.HCEL5025 || objasmsj.fCO25 > m_mainform.COEL5025 || objasmsj.iNO25 > m_mainform.NOEL5025)) ||
               objasmsj.iHC40 > m_mainform.HCEL2540 ||objasmsj.fCO40 > m_mainform.COEL2540 ||objasmsj.iNO40 > m_mainform.NOEL2540)
            {
                bgood = false;
            }
            else
            {
                bgood = true;
            }
            var objjcjg = new 云景model.HJ08();
            if (objasmsj.ASMType == "1" || objasmsj.ASMType == "2")
            {
                objjcjg = new 云景model.HJ08()
                {
                    InspectionNum = businessId,
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    VLPN = m_mainform.VLPN,
                    VLPNColor = m_mainform.VLPNColor,
                    VIN = m_mainform.VIN,
                    InspectionOperator = m_mainform.InspectionOperator,
                    InspectionDriver = m_mainform.InspectionDriver,
                    ICheck = m_mainform.InspectionOperator,
                    CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Temperature = objasmsj.fwendu.ToString("0.00"),
                    Pressure = objasmsj.fdaqiya.ToString("0.00"),
                    Humidity = objasmsj.fshidu.ToString("0.00"),
                    IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                    IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                    DetectStartTime = TESTASM.timeStart,
                    DetectEndTime = timeEnd,
                    VDCT = (bgood && bobdpd) ? "1" : "0",
                    ASMType = objasmsj.ASMType,
                    EACR = "1.01",//问题
                    HCEL5025 = m_mainform.HCEL5025.ToString("0"),
                    HCER5025 = objasmsj.iHC25.ToString("0"),
                    HCED5025 = objasmsj.iHC25 > m_mainform.HCEL5025 ? "0" : "1",
                    COEL5025 = m_mainform.COEL5025.ToString("0.00"),
                    COER5025 = objasmsj.fCO25.ToString("0.00"),
                    COED5025 = objasmsj.fCO25 > m_mainform.COEL5025 ? "0" : "1",
                    NOEL5025 = m_mainform.NOEL5025.ToString("0"),
                    NOER5025 = objasmsj.iNO25.ToString("0"),
                    NOED5025 = objasmsj.iNO25 > m_mainform.NOEL5025 ? "0" : "1"
                };
            }
            else
            {
                objjcjg = new 云景model.HJ08()
                {
                    InspectionNum = businessId,
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    VLPN = m_mainform.VLPN,
                    VLPNColor = m_mainform.VLPNColor,
                    VIN = m_mainform.VIN,
                    InspectionOperator = m_mainform.InspectionOperator,
                    InspectionDriver = m_mainform.InspectionDriver,
                    ICheck = m_mainform.InspectionOperator,
                    CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Temperature = objasmsj.fwendu.ToString("0.0"),
                    Pressure = objasmsj.fdaqiya.ToString("0.0"),
                    Humidity = objasmsj.fshidu.ToString("0.0"),
                    IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                    IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                    DetectStartTime = TESTASM.timeStart,
                    DetectEndTime = timeEnd,
                    VDCT = (bgood && bobdpd) ? "1" : "0",
                    ASMType = objasmsj.ASMType,
                    EACR = "1.01",//问题
                    HCEL5025 = m_mainform.HCEL5025.ToString("0"),
                    HCER5025 = objasmsj.iHC25.ToString("0"),
                    HCED5025 = objasmsj.iHC25 > m_mainform.HCEL5025 ? "0" : "1",
                    COEL5025 = m_mainform.COEL5025.ToString("0.00"),
                    COER5025 = objasmsj.fCO25.ToString("0.00"),
                    COED5025 = objasmsj.fCO25 > m_mainform.COEL5025 ? "0" : "1",
                    NOEL5025 = m_mainform.NOEL5025.ToString("0"),
                    NOER5025 = objasmsj.iNO25.ToString("0"),
                    NOED5025 = objasmsj.iNO25 > m_mainform.NOEL5025 ? "0" : "1",
                    HCEL2540 = m_mainform.HCEL2540.ToString("0"),
                    HCER2540 = objasmsj.iHC40.ToString("0"),
                    HCED2540 = objasmsj.iHC40 > m_mainform.HCEL2540 ? "0" : "1",
                    COEL2540 = m_mainform.COEL2540.ToString("0.00"),
                    COER2540 = objasmsj.fCO40.ToString("0.00"),
                    COED2540 = objasmsj.fCO40 > m_mainform.COEL2540 ? "0" : "1",
                    NOEL2540 = m_mainform.NOEL2540.ToString("0"),
                    NOER2540 = objasmsj.iNO40.ToString("0"),
                    NOED2540 = objasmsj.iNO40 > m_mainform.NOEL2540 ? "0" : "1"
                };
            }

            string svalue = JsonConvert.SerializeObject(objjcjg);
            string sjieguo = m_mainform.objbass.senddate("HJ08", svalue);
            //m_mainform.baocunriji("HJ08", svalue);
            //m_mainform.baocunriji("HJ08结果", sjieguo);

            stopex(businessId,"");
            return "1";
        }

        public override string sjuploadSDS(string businessId, model.SDS.SDSsj objsj, model.SDS.SDSgcsj objgcsj, model.ASM.ASMobdgcsj objasmobd)
        {
            updateljh();//刷新累积号
            int ilandapd = 1;
            if (!bydhh && (objsj.fLAMDAG > 1.05 || objsj.fLAMDAG < 0.95))
            {
                ilandapd = 0;
            }
            string lamda = objsj.fLAMDAG.ToString("0.00");
            var objsdsjcjg = new 云景model.HJ12();
            if (objsj.iHCG > m_mainform.HIHCL || objsj.fCOG > m_mainform.HICOL || (!bydhh && (objsj.fLAMDAG > 1.05f || objsj.fLAMDAG < 0.95f)))
            {
                objsdsjcjg = new 云景model.HJ12()
                {
                    InspectionNum = businessId,
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    VLPN = m_mainform.VLPN,
                    VLPNColor = m_mainform.VLPNColor,
                    VIN = m_mainform.VIN,
                    InspectionOperator = m_mainform.InspectionOperator,
                    InspectionDriver = m_mainform.InspectionDriver,
                    ICheck = m_mainform.InspectionOperator,
                    CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Temperature = objsj.fwendu.ToString("0.00"),
                    Pressure = objsj.fdaqiya.ToString("0.00"),
                    Humidity = objsj.fshidu.ToString("0.00"),
                    IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                    IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                    DetectStartTime = TESTSDS.timeStart,
                    DetectEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    VDCT = (objsj.bgood && bobdpd) ? "1" : "0",
                    EACR = lamda,
                    EACLU = bydhh ? "" : "1.05",
                    EACLD = bydhh ? "" : "0.95",
                    EACD = string.Format("{0}", ilandapd),
                    HICOR = objsj.fCOG.ToString("0.00"),
                    HICOL = m_mainform.HICOL.ToString("0.00"),
                    HICOD = objsj.fCOG > m_mainform.HICOL ? "0" : "1",
                    HIHCR = objsj.iHCG.ToString("0"),
                    HIHCL = m_mainform.HIHCL.ToString("0"),
                    HIHCD = objsj.iHCG > m_mainform.HIHCL ? "0" : "1"
                };
            }
            else
            {
                objsdsjcjg = new 云景model.HJ12()
                {
                    InspectionNum = businessId,
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    VLPN = m_mainform.VLPN,
                    VLPNColor = m_mainform.VLPNColor,
                    VIN = m_mainform.VIN,
                    InspectionOperator = m_mainform.InspectionOperator,
                    InspectionDriver = m_mainform.InspectionDriver,
                    ICheck = m_mainform.InspectionOperator,
                    CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Temperature = objsj.fwendu.ToString("0.0"),
                    Pressure = objsj.fdaqiya.ToString("0.0"),
                    Humidity = objsj.fshidu.ToString("0.0"),
                    IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                    IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                    DetectStartTime = TESTSDS.timeStart,
                    DetectEndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    VDCT = (objsj.bgood && bobdpd) ? "1" : "0",
                    EACR = lamda,
                    EACLU = bydhh ? "" : "1.05",
                    EACLD = bydhh ? "" : "0.95",
                    EACD = string.Format("{0}", ilandapd),
                    LICOR = objsj.fCOD.ToString("0.00"),
                    LICOL = m_mainform.LICOL.ToString("0.00"),
                    LICOD = objsj.fCOD > m_mainform.LICOL ? "0" : "1",
                    LIHCR = objsj.iHCD.ToString("0"),
                    LIHCL = m_mainform.LIHCL.ToString("0"),
                    LIHCD = objsj.iHCD > m_mainform.LIHCL ? "0" : "1",
                    HICOR = objsj.fCOG.ToString("0.00"),
                    HICOL = m_mainform.HICOL.ToString("0.00"),
                    HICOD = objsj.fCOG > m_mainform.HICOL ? "0" : "1",
                    HIHCR = objsj.iHCG.ToString("0"),
                    HIHCL = m_mainform.HIHCL.ToString("0"),
                    HIHCD = objsj.iHCG > m_mainform.HIHCL ? "0" : "1"
                };
            }

            string svalue = JsonConvert.SerializeObject(objsdsjcjg);
            string sjieguo = m_mainform.objbass.senddate("HJ12", svalue);

            //m_mainform.baocunriji("HJ12", svalue);
            //m_mainform.baocunriji("HJ12结果", sjieguo);
            stopex(businessId, "");
            return "1";

        }

        public override string sjuploadZYJS(string businessId, model.ZYJS.ZYJSsj objsj, model.ZYJS.ZYJSgcsj objgcsj, model.LUG.LUGobdgcsj objobdgcsj)
        {
            updateljh();//刷新累积号
            var objjcjg = new 云景model.HJ14()
            {
                InspectionNum = businessId,
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                VLPN = m_mainform.VLPN,
                VLPNColor = m_mainform.VLPNColor,
                VIN = m_mainform.VIN,
                InspectionOperator = m_mainform.InspectionOperator,
                InspectionDriver = m_mainform.InspectionDriver,
                ICheck = m_mainform.InspectionOperator,
                CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Temperature = objsj.fwendu.ToString("0.00"),
                Pressure = objsj.fdaqiya.ToString("0.00"),
                Humidity = objsj.fshidu.ToString("0.00"),
                IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                DetectStartTime = TESTZYJS.timeStart,
                DetectEndTime = TESTZYJS.timeEnd,
                VDCT = (objsj.fSKPJ > m_mainform.InspectionLimits || !bobdpd) ? "0" : "1",
                LPSItem = "1",
                ER1 = objsj.SK1.ToString("0.00"),
                ER2 = objsj.SK2.ToString("0.00"),
                ER3 = objsj.SK3.ToString("0.00"),
                ERA = objsj.fSKPJ.ToString("0.00"),
                ActualRotateSpeed = objsj.m_SKTurn.ToString("0"),
                EL = m_mainform.InspectionLimits.ToString(),
                ED = objsj.fSKPJ > m_mainform.InspectionLimits ? "0" : "1"
            };

            string svalue = JsonConvert.SerializeObject(objjcjg);
            string sjieguo = m_mainform.objbass.senddate("HJ14", svalue);

            //m_mainform.baocunriji("HJ14", svalue);
            //m_mainform.baocunriji("HJ14结果", sjieguo);


            stopex(businessId, "");
            return "1";
        }

        public override string sjuploadLUG(string businessId, model.LUG.LUGsj objsj, model.LUG.LUGgcsj objgcsj, model.LUG.LUGobdgcsj objobdgcsj)
        {
            updateljh();//刷新累积号

            bool bgoodpf = true;
            if (objsj.m_sk100 > m_mainform.TypeApprovalLimits || objsj.m_sk80 > m_mainform.TypeApprovalLimits || objsj.m_sno80 > m_mainform.noxlimit || objsj.fFindMaxPower < objsj.fiedgl * 0.4f)
            {
                bgoodpf = false;
            }
            var objyjsj = new 云景model.HJ16()
            {
                InspectionNum = businessId,
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                VLPN = m_mainform.VLPN,
                VLPNColor = m_mainform.VLPNColor,
                VIN = m_mainform.VIN,
                InspectionOperator = m_mainform.InspectionOperator,
                InspectionDriver = m_mainform.InspectionDriver,
                ICheck = m_mainform.InspectionOperator,
                CheckTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Temperature = objsj.fwendu.ToString("0.00"),
                Pressure = objsj.fdaqiya.ToString("0.00"),
                Humidity = objsj.fshidu.ToString("0.00"),
                IUTID = string.Format("{0}{1}{2}", m_mainform.stationCode, m_mainform.lineCode, m_mainform.IUTID),
                IUIDATE = DateTime.Now.ToString("yyyy-MM-dd"),
                DetectStartTime = TESTLUG.timeStart,
                DetectEndTime = TESTLUG.timeEnd,
                VDCT = objsj.bgood ? "1" : "0",
                ER100 = objsj.m_sk100.ToString("0.00"),
                ER80 = objsj.m_sk80.ToString("0.00"),
                NOX80 = objsj.m_sno80.ToString("0"),
                MWP = objsj.fFindMaxPower.ToString("0.00"),
                EL = m_mainform.TypeApprovalLimits.ToString("0.0"),
                ED = (bgoodpf && bobdpd) ? "1" : "0",
                NOXEL = m_mainform.noxlimit.ToString("0"),
                NOXED = objsj.m_sno80 > m_mainform.noxlimit ? "0" : "1",
                VelMaxHP = objsj.maxpowerspeed.ToString("0.00"),
                LDItem = "1",
                NOX100 = objsj.nox100.ToString("0"),
                VelMaxEnginePower = objsj.zdlbglfdjzs.ToString("0")
            };
            string svalue = JsonConvert.SerializeObject(objyjsj);
            string sjieguo = m_mainform.objbass.senddate("HJ16", svalue);
            //m_mainform.baocunriji("HJ16", svalue);
            //m_mainform.baocunriji("HJ16结果", sjieguo);
            stopex(businessId, "");
            return "1";
        }

        public override string zmgcsjlug(string businessId, model.LUG.LUGgcsjZM objgcsj)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = businessId;
            value["StationCode"] = m_mainform.stationCode;//检测站编码  
            value["SceneCode"] = m_mainform.lineCode;
            value["ProcessTime"] = objgcsj.ProcessTime;          //DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            value["Second_NO"] = objgcsj.iobd.ToString("0");
            value["Flow_RotateSpeed"] = objgcsj.ftrun.ToString("0");
            value["Flow_Speed"] = objgcsj.m_fspeed.ToString("0.00");
            value["Flow_LoadPower"] = objgcsj.fPower.ToString("0.00");
            value["Flow_Torque"] = objgcsj.fnj.ToString("0");
            value["Flow_K"] = objgcsj.m_fsk.ToString("0.00");
            value["Flow_CO2"] = objgcsj.m_fco2sk.ToString("0.00");
            value["Flow_NOX"] = objgcsj.noxz.ToString("0");//objgcsj.m_fnosk.ToString("0");
            value["EnvirTemperature"] = objgcsj.m_fWenDu.ToString("0.00");
            value["EnvirAirPressure"] = objgcsj.m_fYaLi.ToString("0.00");
            value["EnvirHumidity"] = objgcsj.m_fShiDu.ToString("0.00");
            value["EngineOilTemperature"] = objgcsj.m_fyouwenSK.ToString("0.00");
            value["GKLX"] = objgcsj.GKLX.ToString("0");
            value["VelHP"] = objgcsj.m_fzgxsd.ToString("0.00");
            value["PowerCorrect"] = (double.IsInfinity(objgcsj.fpowerK) || double.IsNaN(objgcsj.fpowerK) ? 1 : objgcsj.fpowerK).ToString("0.00");
            value["CorMaxPower"] = (double.IsInfinity(objgcsj.fpowerXZMAX) || double.IsNaN(objgcsj.fpowerXZMAX) ? 1 : objgcsj.fpowerXZMAX).ToString("0.00");// objgcsj.fpowerXZMAX.ToString("0.00");//问题
            value["ActMaxPower"] = (double.IsInfinity(objgcsj.fpowerSCMAX) || double.IsNaN(objgcsj.fpowerSCMAX) ? 1 : objgcsj.fpowerSCMAX).ToString("0.00");// objgcsj.fpowerSCMAX.ToString("0.00");//问题
            value["NFJZXS"] = objgcsj.nlxzxs.ToString("0.00");
            value["NFXS"] = objgcsj.nlxs.ToString("0.00");
            value["NF"] = objgcsj.nlxs.ToString("0.00");//问题
            value["OilTemperature"] = objgcsj.m_fyouwenSK.ToString("0.00");
            value["PowerPerSec"] = objgcsj.fPower.ToString("0.00");

            string svalue = value.ToJson();
            string sjieguo = senddate("HJ15", svalue);
            if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
            {
                return "0";
            }
            else
            {
                return "1";
            }
            //m_mainform.baocunriji("HJ15", svalue);
            //m_mainform.baocunriji("HJ15结果", sjieguo);
        }


        public override string zmgcsjzyjs(string businessId, model.ZYJS.ZYJSgcsjZM objgcsj)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = businessId;
            value["StationCode"] = m_mainform.stationCode;//检测站编码  
            value["SceneCode"] = m_mainform.lineCode;
            value["ProcessTime"] = objgcsj.ProcessTime;//DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            value["Second_NO"] = objgcsj.iobd.ToString("0");
            value["Flow_RotateSpeed"] = objgcsj.fZS.ToString("0");
            value["Flow_K"] = objgcsj.m_fsk.ToString("0.00");
            value["EnvirTemperature"] = objgcsj.m_fWenDu.ToString("0.00");
            value["EnvirAirPressure"] = objgcsj.m_fYaLi.ToString("0.00");
            value["EnvirHumidity"] = objgcsj.m_fShiDu.ToString("0.00");
            value["EngineOilTemperature"] = objgcsj.m_fyouwenSK.ToString("0.0");
            value["GKLX"] = objgcsj.GKLX.ToString("0");

            //string svalue = value.ToJson();
            //sendZYJSGCSJ(businessId, svalue);

            string svalue = value.ToJson();
            string sjieguo = senddate("HJ13", svalue);
            if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
            {
                return "0";
            }
            else
            {
                return "1";
            }
            //m_mainform.baocunriji("HJ13", svalue);
            //m_mainform.baocunriji("HJ13结果", sjieguo);
        }

        public override string zmgcsjasm(string businessId, model.ASM.ASMgcsjZM objgcsj)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = objgcsj.businessId;//受理编码  
            value["StationCode"] = m_mainform.stationCode;//检测站编码  
            value["SceneCode"] = objgcsj.lineCode;//检测线编码  
            value["ProcessTime"] = objgcsj.ProcessTime;          // objgcsj.jcgcdysj;//检测过程数据对应时间  
            value["Second_NO"] = objgcsj.imslsh;//秒数流水号  
            value["Flow_Speed"] = objgcsj.m_SpeedGCSJ.ToString("0.00");//逐秒的车速  
            value["Flow_RotateSpeed"] = objgcsj.m_TrunGCSJ;//逐秒发动机转速  
            value["Flow_Freeweight"] = objgcsj.m_PWGCSJ.ToString("0.00");//逐秒底盘测功机负载  
            value["Flow_HC"] = objgcsj.m_HCGCSJ.ToString("0");//逐秒HC浓度值(未经修正)  
            value["Flow_CO"] = objgcsj.m_COGCSJ.ToString("0.00");//逐秒CO浓度值(未经修正)  
            value["Flow_CO2"] = objgcsj.m_CO2GCSJ.ToString("0.00");//逐秒CO2浓度值(未经修正)  
            value["Flow_NO"] = objgcsj.m_NOGCSJ.ToString("0"); ;//逐秒NO浓度值(未经修正)  
            value["Flow_O2"] = objgcsj.m_O2GCSJ.ToString("0.00");//逐秒O2浓度值(未经修正)  
            value["Flow_HCCorrect"] = objgcsj.m_HCGCSJxz.ToString("0"); ;//逐秒HC浓度值(修正后)  
            value["Flow_COCorrect"] = objgcsj.m_COGCSJxz.ToString("0.00");//逐秒CO浓度值(修正后)  
            value["Flow_CO2Correct"] = objgcsj.m_CO2GCSJ.ToString("0.00");//逐秒CO2浓度值(修正后)  
            value["Flow_NOCorrect"] = objgcsj.m_NOGCSJxz.ToString("0.00");//逐秒NO浓度值(修正后)  
            value["Flow_O2Correct"] = objgcsj.m_O2GCSJ.ToString("0.00");//逐秒O2浓度值(修正后)  
            value["Flow_Lambda"] = objgcsj.m_LAMDAGCSJ.ToString("0.00");//逐秒计算的λ值  
            value["DiluteCorrect"] = objgcsj.m_DFGCSJ.ToString("0.00");//逐秒稀释修正系数DF  
            value["NOHumidityCorrect"] = objgcsj.m_KHGCSJ.ToString("0.00");//NO湿度修正系数  
            value["FlowAirPressure"] = objgcsj.sdaqiyi.ToString("0.00");//objgcsj.m_lljqy;//测试工况流量计气压力每秒数据              
            value["FlowTemperature"] = objgcsj.swendu.ToString("0.00");// objgcsj.m_lljwd;//测试工况流量计温度每秒数据  
            value["EnvirTemperature"] = objgcsj.swendu.ToString("0.00");//测试工况环境温度每秒数据  
            value["EnvirAirPressure"] = objgcsj.sdaqiyi.ToString("0.00");//测试工况环境大气压力每秒数据  
            value["EnvirHumidity"] = objgcsj.sshidu.ToString("0.00");//测试工况环境相对湿度每秒数据  
            value["NF"] = objgcsj.m_NLGCSJ.ToString("0.00");//扭力  
            value["NFJZXS"] = objgcsj.m_nlxzxs.ToString("0.00");//扭力校准系数  
            value["NFXS"] = objgcsj.m_nlxs.ToString("0.00");//扭力系数  
            value["GKLX"] = objgcsj.GKLX;//工况过程类型  
            value["Weight_HC"] = objgcsj.m_WeightHC.ToString("0.00");//HC排放质量每秒数据
            value["Weight_CO"] = objgcsj.m_WeightCO.ToString("0.00");//CO排放质量每秒数据
            value["Weight_NO"] = objgcsj.m_WeightNO.ToString("0.00");//NO排放质量每秒数据
            value["ActPower"] = objgcsj.m_ActPower.ToString("0.00");//实测加载功率
            string svalue = value.ToJson();
            string sjieguo = senddate("HJ07", svalue);
            //m_mainform.baocunriji("HJ07", svalue);
            //m_mainform.baocunriji("HJ07结果", sjieguo);

            //sendASMGCSJ(businessId, svalue);
            if (sjieguo.Substring(0, sjieguo.IndexOf(",")) != "1")
            {
                return "0";
            }
            else
            {
                return "1";
            }
        }


        public override string zmgcsjsds(string businessId, model.SDS.SDSgcsjZM objgcsj)
        {
            JsonData value = new LitJson.JsonData();
            value["InspectionNum"] = objgcsj.businessId;       //受理编码
            value["StationCode"] = m_mainform.stationCode;//检测站编码  
            value["SceneCode"] = objgcsj.lineCode;            //检测站编码
            value["ProcessTime"] = objgcsj.ProcessTime;          //检测过程数据对应时间
            value["Second_NO"] = objgcsj.imslsh;              //秒数流水号
            value["Flow_RotateSpeed"] = objgcsj.itrun;        //逐秒发动机转速
            value["Flow_HC"] = objgcsj.m_iHc.ToString("0");                 //逐秒HC浓度值(未经修正)
            value["Flow_CO"] = objgcsj.m_fCo.ToString("0.00");                 //逐秒CO浓度值(未经修正)
            value["Flow_CO2"] = objgcsj.m_fCo2.ToString("0.00");               //逐秒CO2浓度值
            //   value["Flow_NO"] = objgcsj.m_iNo;                 //
            value["Flow_O2"] = objgcsj.m_fO2.ToString("0.00");                 //逐秒O2浓度值
            value["Flow_Lambda"] = objgcsj.m_fLamda.ToString("0.00");          //逐秒计算的λ值
            value["EnvirTemperature"] = objgcsj.m_fWenDu.ToString("0.00");     //测试工况环境温度每秒数据
            value["EnvirAirPressure"] = objgcsj.m_fYaLi.ToString("0.00");      //测试工况环境大气压力每秒数据
            value["EnvirHumidity"] = objgcsj.m_fShiDu.ToString("0.00");        //测试工况环境相对湿度每秒数据
            value["EngineOilTemperature"] = objgcsj.m_fyw.ToString("0.00");            //逐秒发动机机油温度
            value["GKLX"] = objgcsj.GKLX;                     //工况过程类型

            string svalue = value.ToJson();
            string jieguo = senddate("HJ11", svalue);

            if (jieguo.Substring(0, jieguo.IndexOf(",")) != "1")
            {
                return "0";
            }
            else
            {
                return "1";
            }
            //m_mainform.baocunriji("HJ11", svalue);
            //m_mainform.baocunriji("HJ11结果", jieguo);
        }



        //-------------------自检


        public override string uploadhxjc(model.尾气自检.hxjc objhxjc)//日常滑行测试结束后提交滑行结果
        {
            float fsjsj40 = 0;
            float fllsj40 = 0;
            float.TryParse(objhxjc.ActualTime40, out fsjsj40);
            float.TryParse(objhxjc.TheoretialTime40, out fllsj40);
            fsjsj40 = fsjsj40 * 1000;
            fllsj40 = fllsj40 * 1000;
            float fsjsj25 = 0;
            float fllsj25 = 0;
            float.TryParse(objhxjc.ActualTime25, out fsjsj25);
            float.TryParse(objhxjc.TheoretialTime25, out fllsj25);
            fsjsj25 = fsjsj25 * 1000;
            fllsj25 = fllsj25 * 1000;
            //DateTime time = new DateTime();
            //DateTime.TryParse(

            var result = new 云景model.HJ27()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                SlideTimeStart = objhxjc.dtBeginTime,
                DIW = objhxjc.fDIW,
                IHP2540 = objhxjc.LoadPW40,
                PLHP40 = objhxjc.fLossPW40,
                ACDT40 = fsjsj40.ToString("0"),
                CCDT40 = fllsj40.ToString("0"),
                IHP5025 = objhxjc.LoadPW25,
                PLHP25 = objhxjc.fLossPW25,
                ACDT25 = fsjsj25.ToString("0"),
                CCDT25 = fllsj25.ToString("0"),
                SlideCheckJudge40 = "1",
                SlideCheckJudge25 = "1",
                CheckJudge = "1",
                Checker = objhxjc.Checker
            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ27", svalue);


            uploadzjxs(objhxjc);
            return jieguo;
        }



        public override string uploadzj(model.尾气自检.xljc objxljc)//日常检查泄露检查结束后提交检查结果
        {
            var result = new 云景model.HJ35()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                CheckTimeStart = objxljc.dtBeginTime,
                CheckTimeEnd = objxljc.dtEndTime,
                CheckJudge = objxljc.nJudegeResult,
                BelowStandard = "",
                Checker = objxljc.jcry
            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ35", svalue);
            //JsonData value = new LitJson.JsonData();
            //value["StationCode"] = m_mainform.stationCode;
            //value["SceneCode"] = m_mainform.lineCode;
            //value["CheckDate"] = DateTime.Now.ToString("yyyy-MM-dd");
            //value["CheckTimeStart"] = objxljc.dtBeginTime;
            //value["CheckTimeEnd"] = objxljc.dtEndTime;
            //value["CheckJudge"] = objxljc.nJudegeResult;
            //value["BelowStandard"] = "";
            //value["Checker"] = m_mainform.sczyxx;
            //string svalue = value.ToJson();
            //string jieguo = senddate("HJ35", svalue);
            return jieguo;
        }

        public override string uploadzj(model.尾气自检.btgnoxyqjd objxljc)//NOx分析仪单点检查后提交检查结果。
        {
            var result31 = new 云景model.HJ31()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                CheckTimeStart = DateTime.Now.AddMinutes(-5).ToString("yyyy-MM-dd HH:mm:ss"),
                CheckTimeEnd = DateTime.Now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm:ss"),
                C3H8 = "0",
                CO = "0",
                CO2 = "2.0",
                NO = objxljc.StdValNO,
                O2 = "0",
                HCER = "0",
                COER = "0",
                CO2ER = "2.0",
                NOER = objxljc.CheckValNO,
                O2ER = "0",
                PEF = "0",
                NO2 = "0",
                NO2ER = "0",
                NO2ToNOInversionRate = "92",
                DeviceType = "1",
                CheckJudge = "1",
                Checker = objxljc.Checker
            };
            string jieguo = senddate("HJ31", JsonConvert.SerializeObject(result31));
            return jieguo;
        }

        public override string uploadzj(model.尾气自检.fqyddjc objxljc)//废气分析仪单点检查
        {
            string str = "";
            if (objxljc.CheckTypeex.Contains("中低浓度"))
            {
                str = "2";
            }
            else if (objxljc.CheckTypeex.Contains("低浓度"))
            {
                str = "1";
            }
            else if (objxljc.CheckTypeex.Contains("中高浓度"))
            {
                str = "3";
            }
            else if (objxljc.CheckTypeex.Contains("高浓度"))
            {
                str = "4";
            }
            else if (objxljc.CheckTypeex.Contains("零度"))
            {
                str = "5";
            }
            else
            {
                str = "1";
            }

            var result = new 云景model.HJ34()
            {
                StationCode = m_mainform.stationCode,
                SceneCode =      m_mainform.lineCode,
                CheckDate =      DateTime.Now.ToString("yyyy-MM-dd"),
                CheckTimeStart = objxljc.dtBeginTime,
                CheckTimeEnd = objxljc.dtEndTime,
                CheckType = str,
                C3H8 = objxljc.C3H8,
                CO = objxljc.StdValCO,
                CO2 = objxljc.StdValCO2,
                NO = objxljc.StdValNO,
                O2 = objxljc.StdValO2,
                HCER = objxljc.CheckValHC,
                COER = objxljc.CheckValCO,
                CO2ER = objxljc.CheckValCO2,
                NOER = objxljc.CheckValNO,
                O2ER = objxljc.CheckValO2,
                PEF = objxljc.PEF,
                CheckJudge = "1",
                Checker = objxljc.Checker
            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ34", svalue);

            if (objxljc.CheckTypeex.Contains("低浓度"))
            {
                var result31 = new 云景model.HJ31()
                {
                    DeviceType = "2",
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                    CheckTimeStart = objxljc.dtBeginTime,
                    CheckTimeEnd = objxljc.dtEndTime,
                    C3H8 = objxljc.C3H8,
                    CO = objxljc.StdValCO,
                    CO2 = objxljc.StdValCO2,
                    NO = objxljc.StdValNO,
                    O2 = objxljc.StdValO2,
                    HCER = objxljc.CheckValHC,
                    COER = objxljc.CheckValCO,
                    CO2ER = objxljc.CheckValCO2,
                    NOER = objxljc.CheckValNO,
                    O2ER = objxljc.CheckValO2,
                    PEF = objxljc.PEF,
                    NO2 = "0",
                    NO2ER = "0",
                    NO2ToNOInversionRate = "91",
                    CheckJudge = "1",
                    Checker = objxljc.Checker
                };
                jieguo = senddate("HJ31", JsonConvert.SerializeObject(result31));

            }

            if (objxljc.CheckTypeex.Contains("零度"))
            {
                var result32 = new 云景model.HJ32()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                    CheckTimeStart = objxljc.dtBeginTime,
                    CheckTimeEnd = objxljc.dtEndTime,
                    C3H8 = objxljc.C3H8,
                    CO = objxljc.StdValCO,
                    CO2 = objxljc.StdValCO2,
                    NO = objxljc.StdValNO,
                    O2 = objxljc.StdValO2,
                    HCER = objxljc.CheckValHC,
                    COER = objxljc.CheckValCO,
                    CO2ER = objxljc.CheckValCO2,
                    NOER = objxljc.CheckValNO,
                    O2ER = objxljc.CheckValO2,
                    PEF = objxljc.PEF,
                    NO2 = "0",
                    NO2ER = "0",
                    NO2ToNOInversionRate = "92",
                    DeviceType = "2",
                    CheckJudge = "1",
                    Checker = objxljc.Checker
                };
                jieguo = senddate("HJ32", JsonConvert.SerializeObject(result32));
            }

            if (objxljc.CheckTypeex.Contains("高浓度"))
            {
                var result33 = new 云景model.HJ33()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                    CheckTimeStart = objxljc.dtBeginTime,
                    CheckTimeEnd = objxljc.dtEndTime,
                    C3H8 = objxljc.C3H8,
                    CO = objxljc.StdValCO,
                    CO2 = objxljc.StdValCO2,
                    NO = objxljc.StdValNO,
                    O2 = objxljc.StdValO2,
                    T90CO = "0",
                    T90NO = "0",
                    T90O2 = "0",
                    T10CO = "0",
                    T10NO = "0",
                    T10O2 = "0",
                    NO2 = "0",
                    NO2ER = "0",
                    NO2ToNOInversionRate = "92",
                    DeviceType = "2",
                    CheckJudge = "1",
                    Checker = objxljc.Checker
                };
                jieguo = senddate("HJ33", JsonConvert.SerializeObject(result33));
            }
            return jieguo;

        }

        public string uploadzjxs(model.尾气自检.hxjc objxljc)
        {
            float fdiw=0;
            if(!float.TryParse(objxljc.fDIW,out fdiw))
            {
                fdiw=903;
            }
            float fplhp40=m_mainform.getRandom(96,103);
            fplhp40=fplhp40/100f;
           float facdt40 = 1700f*fdiw/2000f/fplhp40;
            facdt40=facdt40*1000f;

            
            float fplhp25=m_mainform.getRandom(96,103);
            fplhp25=fplhp25/100f;
           float facdt25 = (1000f)*fdiw/2000f/fplhp25;
            facdt25=facdt25*1000f;
            var result = new 云景model.HJ28()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                PLTimeStart = DateTime.Now.AddMinutes(-30).ToString("yyyy-MM-dd HH:mm:ss"),
                SlideTimeEnd = DateTime.Now.AddMinutes(-3).ToString("yyyy-MM-dd HH:mm:ss"),
                DIW = objxljc.fDIW,
                PLHP40 = fplhp40.ToString("0.00"),
                ACDT40 = facdt40.ToString("0"),
                PLHP25 = fplhp25.ToString("0.00"),
                ACDT25 = facdt25.ToString("0"),
                CheckJudge = "1",
                Checker = m_mainform.sczyxx

            };

            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + "\\检测自检\\稳态工况设备自检信息.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            objini.Writue("记录", "PLHP25", fplhp25.ToString("0.00"));
            objini.Writue("记录", "PLHP40", fplhp40.ToString("0.00"));
            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ28", svalue);
            return jieguo;
        }

        public override string jianceqianzj(string sjylsh, model.尾气自检.检测前自检.ziasm objzj)
        {
            if (objzj.bzjbz)
            {
                var result = new 云景model.HJ21()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    ACDT40 = objzj.ACDT40,
                    CCDT40 = objzj.CCDT40,
                    CDT40_Error = objzj.CDT40_Error,
                    CDT40_Judge = objzj.CDT40_Judge,
                    ACDT25 = objzj.ACDT25,
                    CCDT25 = objzj.CCDT25,
                    CDT25_Error = objzj.CDT25_Error,
                    CDT25_Judge = objzj.CDT25_Judge,
                    PLHP25 = objzj.PLHP25,
                    PLHP40 = objzj.PLHP40,
                    PressureGage_Judge = objzj.PressureGage_Judge,
                    Low_HC = objzj.Low_HC,
                    Low_HC_Error = objzj.Low_HC_Error,
                    Low_HC_Judge = objzj.Low_HC_Judge,
                    Low_CO = objzj.Low_CO,
                    Low_CO_Error = objzj.Low_CO_Error,
                    Low_CO_Judge = objzj.Low_CO_Judge,
                    Low_NO = objzj.Low_NO,
                    Low_NO_Error = objzj.Low_NO_Error,
                    Low_NO_Judge = objzj.Low_NO_Judge,
                    ML_HC = objzj.ML_HC,
                    ML_HC_Error = objzj.ML_HC_Error,
                    ML_HC_Judge = objzj.ML_HC_Judge,
                    ML_CO = objzj.ML_CO,
                    ML_CO_Error = objzj.ML_CO_Error,
                    ML_CO_Judge = objzj.ML_CO_Judge,
                    ML_NO = objzj.ML_NO,
                    ML_NO_Error = objzj.ML_NO_Error,
                    ML_NO_Judge = objzj.ML_NO_Judge,
                    Medium_HC = objzj.Medium_HC,
                    Medium_HC_Error = objzj.Medium_HC_Error,
                    Medium_HC_Judge = objzj.Medium_HC_Judge,
                    Medium_CO = objzj.Medium_CO,
                    Medium_CO_Error = objzj.Medium_CO_Error,
                    Medium_CO_Judge = objzj.Medium_CO_Judge,
                    Medium_NO = objzj.Medium_NO,
                    Medium_NO_Error = objzj.Medium_NO_Error,
                    Medium_NO_Judge = objzj.Medium_NO_Judge,
                    MH_HC = objzj.MH_HC,
                    MH_HC_Error = objzj.MH_HC_Error,
                    MH_HC_Judge = objzj.MH_HC_Judge,
                    MH_CO = objzj.MH_CO,
                    MH_CO_Error = objzj.MH_CO_Error,
                    MH_CO_Judge = objzj.MH_CO_Judge,
                    MH_NO = objzj.MH_NO,
                    MH_NO_Error = objzj.MH_NO_Error,
                    MH_NO_Judge = objzj.MH_NO_Judge,
                    High_HC = objzj.High_HC,
                    High_HC_Error = objzj.High_HC_Error,
                    High_HC_Judge = objzj.High_HC_Judge,
                    High_CO = objzj.High_CO,
                    High_CO_Error = objzj.High_CO_Error,
                    High_CO_Judge = objzj.High_CO_Judge,
                    High_NO = objzj.High_NO,
                    High_NO_Error = objzj.High_NO_Error,
                    High_NO_Judge = objzj.High_NO_Judge,
                    N1000 = objzj.N1000,
                    N1000_Error = objzj.N1000_Error,
                    N1000_Judge = objzj.N1000_Judge,
                    N2000 = objzj.N2000,
                    N2000_Error = objzj.N2000_Error,
                    N2000_Judge = objzj.N2000_Judge,
                    N3000 = objzj.N3000,
                    N3000_Error = objzj.N3000_Error,
                    N3000_Judge = objzj.N3000_Judge,
                    N4000 = objzj.N4000,
                    N4000_Error = objzj.N4000_Error,
                    N4000_Judge = objzj.N4000_Judge,
                    Judge = objzj.Judge,
                    CheckTimeStart = objzj.CheckTimeStart,
                    CheckTimeEnd = objzj.CheckTimeEnd,
                    Zero_HC = objzj.Zero_HC,
                    Zero_HC_Error = objzj.Zero_HC_Error,
                    Zero_HC_Judge = objzj.Zero_HC_Judge,
                    Zero_CO = objzj.Zero_CO,
                    Zero_CO_Error = objzj.Zero_CO_Error,
                    Zero_CO_Judge = objzj.Zero_CO_Judge,
                    Zero_NO = objzj.Zero_NO,
                    Zero_NO_Error = objzj.Zero_NO_Error,
                    Zero_NO_Judge = objzj.Zero_NO_Judge

                };
                string svalue = JsonConvert.SerializeObject(result);
                string jieguo = senddate("HJ21", svalue);
                return jieguo;
            }
            return "成功";
        }

        public override string jianceqianzj(string sjylsh, model.尾气自检.检测前自检.zijiansds objzj)
        {
            if (objzj.bzjbz)
            {
                var result = new 云景model.HJ22()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    Low_HC = objzj.Low_HC,
                    Low_HC_Error = objzj.Low_HC_Error,
                    Low_HC_Judge = objzj.Low_HC_Judge,
                    Low_CO = objzj.Low_CO,
                    Low_CO_Error = objzj.Low_CO_Error,
                    Low_CO_Judge = objzj.Low_CO_Judge,
                    ML_HC = objzj.ML_HC,
                    ML_HC_Error = objzj.ML_HC_Error,
                    ML_HC_Judge = objzj.ML_HC_Judge,
                    ML_CO = objzj.ML_CO,
                    ML_CO_Error = objzj.ML_CO_Error,
                    ML_CO_Judge = objzj.ML_CO_Judge,
                    Medium_HC = objzj.Medium_HC,
                    Medium_HC_Error = objzj.Medium_HC_Error,
                    Medium_HC_Judge = objzj.Medium_HC_Judge,
                    Medium_CO = objzj.Medium_CO,
                    Medium_CO_Error = objzj.Medium_CO_Error,
                    Medium_CO_Judge = objzj.Medium_CO_Judge,
                    MH_HC = objzj.MH_HC,
                    MH_HC_Error = objzj.MH_HC_Error,
                    MH_HC_Judge = objzj.MH_HC_Judge,
                    MH_CO = objzj.MH_CO,
                    MH_CO_Error = objzj.MH_CO_Error,
                    MH_CO_Judge = objzj.MH_CO_Judge,
                    High_HC = objzj.High_HC,
                    High_HC_Error = objzj.High_HC_Error,
                    High_HC_Judge = objzj.High_HC_Judge,
                    High_CO = objzj.High_CO,
                    High_CO_Error = objzj.High_CO_Error,
                    High_CO_Judge = objzj.High_CO_Judge,
                    N1000 = objzj.N1000,
                    N1000_Error = objzj.N1000_Error,
                    N1000_Judge = objzj.N1000_Judge,
                    N2000 = objzj.N2000,
                    N2000_Error = objzj.N2000_Error,
                    N2000_Judge = objzj.N2000_Judge,
                    N3000 = objzj.N3000,
                    N3000_Error = objzj.N3000_Error,
                    N3000_Judge = objzj.N3000_Judge,
                    N4000 = objzj.N4000,
                    N4000_Error = objzj.N4000_Error,
                    N4000_Judge = objzj.N4000_Judge,
                    Judge = objzj.Judge,
                    CheckTimeStart = objzj.CheckTimeStart,
                    CheckTimeEnd = objzj.CheckTimeEnd,
                    Zero_HC = objzj.Zero_HC,
                    Zero_HC_Error = objzj.Zero_HC_Error,
                    Zero_HC_Judge = objzj.Zero_HC_Judge,
                    Zero_CO = objzj.Zero_CO,
                    Zero_CO_Error = objzj.Zero_CO_Error,
                    Zero_CO_Judge = objzj.Zero_CO_Judge

                };
                string svalue = JsonConvert.SerializeObject(result);
                string jieguo = senddate("HJ22", svalue);
                return jieguo;
            }
            return "成功";
        }

        public override string jianceqianzj(string sjylsh, model.尾气自检.检测前自检.zijianlug objzj)
        {
            if (objzj.bzjbz)
            {
                var result = new 云景model.HJ20()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    ACDT40 = objzj.ACDT40,
                    CCDT40 = objzj.CCDT40,
                    CDT40_Error = objzj.CDT40_Error,
                    CDT40_Judge = objzj.CDT40_Judge,
                    ACDT56 = objzj.ACDT56,
                    CCDT56 = objzj.CCDT56,
                    CDT56_Error = objzj.CDT56_Error,
                    CDT56_Judge = objzj.CDT56_Judge,
                    PLHP24 = objzj.PLHP24,
                    PLHP32 = objzj.PLHP32,
                    PLHP40 = objzj.PLHP40,
                    PLHP48 = objzj.PLHP48,
                    PLHP56 = objzj.PLHP56,
                    PLHP64 = objzj.PLHP64,
                    PLHP72 = objzj.PLHP72,
                    PLHP80 = objzj.PLHP80,
                    PLHP88 = objzj.PLHP88,
                    PressureGage_Judge = objzj.PressureGage_Judge,
                    N30 = objzj.N30,
                    N30_Error = objzj.N30_Error,
                    N30_Judge = objzj.N30_Judge,
                    N50 = objzj.N50,
                    N50_Error = objzj.N50_Error,
                    N50_Judge = objzj.N50_Judge,
                    N70 = objzj.N70,
                    N70_Error = objzj.N70_Error,
                    N70_Judge = objzj.N70_Judge,
                    N1000 = objzj.N1000,
                    N1000_Error = objzj.N1000_Error,
                    N1000_Judge = objzj.N1000_Judge,
                    N2000 = objzj.N2000,
                    N2000_Error = objzj.N2000_Error,
                    N2000_Judge = objzj.N2000_Judge,
                    N3000 = objzj.N3000,
                    N3000_Error = objzj.N3000_Error,
                    N3000_Judge = objzj.N3000_Judge,
                    N4000 = objzj.N4000,
                    N4000_Error = objzj.N4000_Error,
                    N4000_Judge = objzj.N4000_Judge,
                    Judge = objzj.Judge,
                    CheckTimeStart = objzj.CheckTimeStart,
                    CheckTimeEnd = objzj.CheckTimeEnd

                };
                string svalue = JsonConvert.SerializeObject(result);
                string jieguo = senddate("HJ20", svalue);
                return jieguo;
            }
            return "成功";
        }

        public override string jianceqianzj(string sjylsh, model.尾气自检.检测前自检.zijianzyjs objzj)
        {
            if (objzj.bzjbz)
            {
                var result = new 云景model.HJ19()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    N0 = objzj.N0,
                    N0_Error = objzj.N0_Error,
                    N0_Judge = objzj.N0_Judge,
                    N30 = objzj.N30,
                    N30_Error = objzj.N30_Error,
                    N30_Judge = objzj.N30_Judge,
                    N50 = objzj.N50,
                    N50_Error = objzj.N50_Error,
                    N50_Judge = objzj.N50_Judge,
                    N70 = objzj.N70,
                    N70_Error = objzj.N70_Error,
                    N70_Judge = objzj.N70_Judge,
                    N90 = objzj.N90,
                    N90_Error = objzj.N90_Error,
                    N90_Judge = objzj.N90_Judge,
                    N100 = objzj.N100,
                    N100_Error = objzj.N100_Error,
                    N100_Judge = objzj.N100_Judge,
                    N1000 = objzj.N1000,
                    N1000_Error = objzj.N1000_Error,
                    N1000_Judge = objzj.N1000_Judge,
                    N1500 = objzj.N1500,
                    N1500_Error = objzj.N1500_Error,
                    N1500_Judge = objzj.N1500_Judge,
                    N2000 = objzj.N2000,
                    N2000_Error = objzj.N2000_Error,
                    N2000_Judge = objzj.N2000_Judge,
                    Judge = objzj.Judge,
                    CheckTimeStart = objzj.CheckTimeStart,
                    CheckTimeEnd = objzj.CheckTimeEnd

                };
                string svalue = JsonConvert.SerializeObject(result);
                string jieguo = senddate("HJ19", svalue);
                return jieguo;
            }
            return "成功";
        }


        public override string JCZT(string szt)
        {
            var result = new 云景model.HJ17()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                DStatus = "01",
                StatusRemark = "",
                RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ17", svalue);
            return jieguo;
        }


        public override string uploadzj(string tph,model.尾气自检.cyhxsj objxljc)//9.30	上报柴油车底盘测功机滑行检查记录表
        {
            if (tph.Contains("10"))
            {
                objxljc.IHP20ACDT90="0" ;
                objxljc.IHP20ACDT80="0" ;
                objxljc.IHP20ACDT70="0" ;
                objxljc.IHP20ACDT60="0" ;
                objxljc.IHP20ACDT50="0" ;
                objxljc.IHP20ACDT40="0" ;
                objxljc.IHP20ACDT30="0" ;
                objxljc.IHP20ACDT20="0" ;
                objxljc.IHP20CCDT90="0" ;
                objxljc.IHP20CCDT80="0" ;
                objxljc.IHP20CCDT70="0" ;
                objxljc.IHP20CCDT60="0" ;
                objxljc.IHP20CCDT50="0" ;
                objxljc.IHP20CCDT40="0" ;
                objxljc.IHP20CCDT30="0" ;
                objxljc.IHP20CCDT20 ="0";

                objxljc.IHP30ACDT90="0" ;
                objxljc.IHP30ACDT80="0" ;
                objxljc.IHP30ACDT70="0" ;
                objxljc.IHP30ACDT60="0" ;
                objxljc.IHP30ACDT50="0" ;
                objxljc.IHP30ACDT40="0" ;
                objxljc.IHP30ACDT30="0" ;
                objxljc.IHP30ACDT20="0" ;
                objxljc.IHP30CCDT90="0" ;
                objxljc.IHP30CCDT80="0" ;
                objxljc.IHP30CCDT70="0" ;
                objxljc.IHP30CCDT60="0" ;
                objxljc.IHP30CCDT50="0" ;
                objxljc.IHP30CCDT40="0" ;
                objxljc.IHP30CCDT30="0" ;
                objxljc.IHP30CCDT20 ="0";
            }

            if (tph.Contains("20"))
            {
                objxljc.IHP30ACDT90="0" ;
                objxljc.IHP30ACDT80="0" ;
                objxljc.IHP30ACDT70="0" ;
                objxljc.IHP30ACDT60="0" ;
                objxljc.IHP30ACDT50="0" ;
                objxljc.IHP30ACDT40="0" ;
                objxljc.IHP30ACDT30="0" ;
                objxljc.IHP30ACDT20="0" ;
                objxljc.IHP30CCDT90="0" ;
                objxljc.IHP30CCDT80="0" ;
                objxljc.IHP30CCDT70="0" ;
                objxljc.IHP30CCDT60="0" ;
                objxljc.IHP30CCDT50="0" ;
                objxljc.IHP30CCDT40="0" ;
                objxljc.IHP30CCDT30="0" ;
                objxljc.IHP30CCDT20 ="0";
                           
                objxljc.IHP10ACDT90 = "0";
                objxljc.IHP10ACDT80 = "0";
                objxljc.IHP10ACDT70 = "0";
                objxljc.IHP10ACDT60 = "0";
                objxljc.IHP10ACDT50 = "0";
                objxljc.IHP10ACDT40 = "0";
                objxljc.IHP10ACDT30 = "0";
                objxljc.IHP10ACDT20 = "0";
                objxljc.IHP10CCDT90 = "0";
                objxljc.IHP10CCDT80 = "0";
                objxljc.IHP10CCDT70 = "0";
                objxljc.IHP10CCDT60 = "0";
                objxljc.IHP10CCDT50 = "0";
                objxljc.IHP10CCDT40 = "0";
                objxljc.IHP10CCDT30 = "0";
                objxljc.IHP10CCDT20 = "0";
            }

            if (tph.Contains("30"))
            {
                objxljc.IHP20ACDT90 = "0";
                objxljc.IHP20ACDT80 = "0";
                objxljc.IHP20ACDT70 = "0";
                objxljc.IHP20ACDT60 = "0";
                objxljc.IHP20ACDT50 = "0";
                objxljc.IHP20ACDT40 = "0";
                objxljc.IHP20ACDT30 = "0";
                objxljc.IHP20ACDT20 = "0";
                objxljc.IHP20CCDT90 = "0";
                objxljc.IHP20CCDT80 = "0";
                objxljc.IHP20CCDT70 = "0";
                objxljc.IHP20CCDT60 = "0";
                objxljc.IHP20CCDT50 = "0";
                objxljc.IHP20CCDT40 = "0";
                objxljc.IHP20CCDT30 = "0";
                objxljc.IHP20CCDT20 = "0";

                objxljc.IHP10ACDT90 = "0";
                objxljc.IHP10ACDT80 = "0";
                objxljc.IHP10ACDT70 = "0";
                objxljc.IHP10ACDT60 = "0";
                objxljc.IHP10ACDT50 = "0";
                objxljc.IHP10ACDT40 = "0";
                objxljc.IHP10ACDT30 = "0";
                objxljc.IHP10ACDT20 = "0";
                objxljc.IHP10CCDT90 = "0";
                objxljc.IHP10CCDT80 = "0";
                objxljc.IHP10CCDT70 = "0";
                objxljc.IHP10CCDT60 = "0";
                objxljc.IHP10CCDT50 = "0";
                objxljc.IHP10CCDT40 = "0";
                objxljc.IHP10CCDT30 = "0";
                objxljc.IHP10CCDT20 = "0";
            }
            var result = new 云景model.HJ29()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                SlideTimeStart = objxljc.SlideTimeStart,
                DIW = objxljc.DIW,
                IHP30ACDT90 = objxljc.IHP30ACDT90,
                IHP30ACDT80 = objxljc.IHP30ACDT80,
                IHP30ACDT70 = objxljc.IHP30ACDT70,
                IHP30ACDT60 = objxljc.IHP30ACDT60,
                IHP30ACDT50 = objxljc.IHP30ACDT50,
                IHP30ACDT40 = objxljc.IHP30ACDT40,
                IHP30ACDT30 = objxljc.IHP30ACDT30,
                IHP30ACDT20 = objxljc.IHP30ACDT20,
                IHP30CCDT90 = objxljc.IHP30CCDT90,
                IHP30CCDT80 = objxljc.IHP30CCDT80,
                IHP30CCDT70 = objxljc.IHP30CCDT70,
                IHP30CCDT60 = objxljc.IHP30CCDT60,
                IHP30CCDT50 = objxljc.IHP30CCDT50,
                IHP30CCDT40 = objxljc.IHP30CCDT40,
                IHP30CCDT30 = objxljc.IHP30CCDT30,
                IHP30CCDT20 = objxljc.IHP30CCDT20,
                IHP20ACDT90 = objxljc.IHP20ACDT90,
                IHP20ACDT80 = objxljc.IHP20ACDT80,
                IHP20ACDT70 = objxljc.IHP20ACDT70,
                IHP20ACDT60 = objxljc.IHP20ACDT60,
                IHP20ACDT50 = objxljc.IHP20ACDT50,
                IHP20ACDT40 = objxljc.IHP20ACDT40,
                IHP20ACDT30 = objxljc.IHP20ACDT30,
                IHP20ACDT20 = objxljc.IHP20ACDT20,
                IHP20CCDT90 = objxljc.IHP20CCDT90,
                IHP20CCDT80 = objxljc.IHP20CCDT80,
                IHP20CCDT70 = objxljc.IHP20CCDT70,
                IHP20CCDT60 = objxljc.IHP20CCDT60,
                IHP20CCDT50 = objxljc.IHP20CCDT50,
                IHP20CCDT40 = objxljc.IHP20CCDT40,
                IHP20CCDT30 = objxljc.IHP20CCDT30,
                IHP20CCDT20 = objxljc.IHP20CCDT20,
                IHP10ACDT90 = objxljc.IHP10ACDT90,
                IHP10ACDT80 = objxljc.IHP10ACDT80,
                IHP10ACDT70 = objxljc.IHP10ACDT70,
                IHP10ACDT60 = objxljc.IHP10ACDT60,
                IHP10ACDT50 = objxljc.IHP10ACDT50,
                IHP10ACDT40 = objxljc.IHP10ACDT40,
                IHP10ACDT30 = objxljc.IHP10ACDT30,
                IHP10ACDT20 = objxljc.IHP10ACDT20,
                IHP10CCDT90 = objxljc.IHP10CCDT90,
                IHP10CCDT80 = objxljc.IHP10CCDT80,
                IHP10CCDT70 = objxljc.IHP10CCDT70,
                IHP10CCDT60 = objxljc.IHP10CCDT60,
                IHP10CCDT50 = objxljc.IHP10CCDT50,
                IHP10CCDT40 = objxljc.IHP10CCDT40,
                IHP10CCDT30 = objxljc.IHP10CCDT30,
                IHP10CCDT20 = objxljc.IHP10CCDT20,
                PLHP90 = objxljc.PLHP90,
                PLHP80 = objxljc.PLHP80,
                PLHP70 = objxljc.PLHP70,
                PLHP60 = objxljc.PLHP60,
                PLHP50 = objxljc.PLHP50,
                PLHP40 = objxljc.PLHP40,
                PLHP30 = objxljc.PLHP30,
                PLHP20 = objxljc.PLHP20,
                SlideCheckJudge100 = objxljc.SlideCheckJudge100,
                SlideCheckJudge80 = objxljc.SlideCheckJudge80,
                CheckJudge = objxljc.CheckJudge,
                Checker = objxljc.Checker
            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ29", svalue);
            return jieguo;
        }

        public override string uploadzj(model.尾气自检.cyfjgl objxljc)//9.30	上报柴油车底盘测功机滑行检查记录表
        {
            var result = new 云景model.HJ30()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                PLTimeStart = objxljc.PLTimeStart,
                SlideTimeEnd = objxljc.SlideTimeEnd,
                DIW = objxljc.DIW,
                ACDT90 = objxljc.ACDT90,
                ACDT80 = objxljc.ACDT80,
                ACDT70 = objxljc.ACDT70,
                ACDT60 = objxljc.ACDT60,
                ACDT50 = objxljc.ACDT50,
                ACDT40 = objxljc.ACDT40,
                ACDT30 = objxljc.ACDT30,
                ACDT20 = objxljc.ACDT20,
                PLHP90 = objxljc.PLHP90,
                PLHP80 = objxljc.PLHP80,
                PLHP70 = objxljc.PLHP70,
                PLHP60 = objxljc.PLHP60,
                PLHP50 = objxljc.PLHP50,
                PLHP40 = objxljc.PLHP40,
                PLHP30 = objxljc.PLHP30,
                PLHP20 = objxljc.PLHP20,
                CheckJudge = objxljc.CheckJudge,
                Checker = objxljc.Checker
            };

            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ30", svalue);
            return jieguo;
        }

        public override string uploadzj(model.尾气自检.fjgl objxljc)
        {
            var result = new 云景model.HJ28()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                PLTimeStart = objxljc.PLTimeStart,
                SlideTimeEnd = objxljc.SlideTimeEnd,
                DIW = objxljc.DIW,
                PLHP40 = objxljc.PLHP40,
                ACDT40 = objxljc.ACDT40,
                PLHP25 = objxljc.PLHP25,
                ACDT25 = objxljc.ACDT25,
                CheckJudge = "1",
                Checker = objxljc.Checker,
            };
            string svalue = JsonConvert.SerializeObject(result);
            string jieguo = senddate("HJ28", svalue);
            return jieguo;
        }

        public override string uploadzj(联网通信协议.云景model.HJ24 objbdqy)
        {
            var obj = new 联网通信协议.云景model.HJ24()
            {

                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                GasType = objbdqy.GasType,
                HCEL = objbdqy.HCEL,
                HCER = objbdqy.HCER,
                HCED = objbdqy.HCED,
                COEL = objbdqy.COEL,
                COER = objbdqy.COER,
                COED = objbdqy.COED,
                NOEL = objbdqy.NOEL,
                NOER = objbdqy.NOER,
                NOED = objbdqy.NOED,
                CO2EL = objbdqy.CO2EL,
                CO2ER = objbdqy.CO2ER,
                CO2ED = objbdqy.CO2ED,
                O2EL = objbdqy.O2EL,
                O2ER = objbdqy.O2ER,
                O2ED = objbdqy.O2ED,
                PEF = objbdqy.PEF,
                C3H8 = objbdqy.C3H8,
                AdjustResult = objbdqy.AdjustResult,
                AdjustTimeStart = objbdqy.AdjustTimeStart,
                AdjustTimeEnd = objbdqy.AdjustTimeEnd,
            };
            string svalue = JsonConvert.SerializeObject(obj);
            string jieguo = senddate("HJ24", svalue);
            return jieguo;
        }
        public override string uploadzj(联网通信协议.云景model.HJ25 objbdcy)
        {
            var obj = new 联网通信协议.云景model.HJ25()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                EL = objbdcy.EL,
                ER = objbdcy.ER,
                ED = objbdcy.ED,
                NOX = objbdcy.NOX,
                NOXEL = objbdcy.NOXEL,
                NOXED = objbdcy.NOXED,
                AdjustTimeStart = objbdcy.AdjustTimeStart,
                AdjustTimeEnd = objbdcy.AdjustTimeEnd,
            };
            string svalue = JsonConvert.SerializeObject(obj);
            string jieguo = senddate("HJ25", svalue);
            return jieguo;
        }


        public override string uploadzj(model.尾气自检.btgydjjc objzjsj)//烟度校准 BD000 6
        {
            var obj = new 联网通信协议.云景model.HJ36()
            {
                StationCode = m_mainform.stationCode,
                SceneCode = m_mainform.lineCode,
                CheckDate = DateTime.Now.ToString("yyyy-MM-dd"),
                CheckTimeStart = DateTime.Now.ToString("yyyy-MM-dd  HH:mm:ss"),
                CheckTimeEnd = DateTime.Now.AddMinutes(1).ToString("yyyy-MM-dd  HH:mm:ss"),
                PLAC = (m_mainform.getRandom(2, 5) + m_mainform.getRandom(2, 8)*0.1).ToString(),
                ResponseTime = ((m_mainform.getRandom(2, 5)*100)).ToString(),
                TC = (m_mainform.getRandom(2, 4) + m_mainform.getRandom(2, 6) * 0.1).ToString(),
                CheckJudge = "1",
                Checker = objzjsj.Checker,
                BelowStandard = "",
            };
            string svalue = JsonConvert.SerializeObject(obj);
            string jieguo = senddate("HJ36", svalue);
            return jieguo;
            return "";
        }

        public override 报告单.modelbgd getbaogaodan(string slsh)//获取登录车辆上线
        {
            string ssql = string.Format("SELECT * FROM YJHJ03,Detects_SJE where YJHJ03.InspectionNum=Detects_SJE.ASM_JYLSH and YJHJ03.InspectionNum='{0}'  order by YJHJ03.id", slsh);
            DataTable dt = objdb.GetTable(ssql);
            报告单.modelbgd objbgd = new 报告单.modelbgd();
            if (dt.Rows.Count > 0)
            {
                objbgd.lsh = dt.Rows[0]["DETECT_ID"].ToString().Trim();
                objbgd.hphm = dt.Rows[0]["VLPN"].ToString().Trim();
                objbgd.hpys = gethpys(dt.Rows[0]["VLPNColor"].ToString().Trim());
                objbgd.clxh = dt.Rows[0]["GAVType"].ToString().Trim();
                objbgd.jzzl = dt.Rows[0]["BenchmarkMass"].ToString().Trim();
                objbgd.vin = dt.Rows[0]["VIN"].ToString().Trim();
                objbgd.edzs = dt.Rows[0]["EngineRatedSpeed"].ToString().Trim();
                objbgd.zdzzl = dt.Rows[0]["VML"].ToString().Trim();
                objbgd.rllb = dt.Rows[0]["FuelType"].ToString().Trim();
                objbgd.gyfs = getgyfs(dt.Rows[0]["OilSupplyWay"].ToString().Trim());//供油方式
                objbgd.edgl = dt.Rows[0]["EnginePower"].ToString().Trim();
                float fglxz = 0;
                float.TryParse(dt.Rows[0]["EnginePower"].ToString().Trim(), out fglxz);
                fglxz = fglxz * 0.4f;
                if (dt.Rows[0]["InspectionMethod"].ToString().Trim().Contains("A"))
                {
                    objbgd.JCFF = string.Format("双怠速法");
                    objbgd.GHC = dt.Rows[0]["HHC"].ToString().Trim();
                    objbgd.GCO = dt.Rows[0]["HCO"].ToString().Trim();
                    objbgd.HC = dt.Rows[0]["LHC"].ToString().Trim();
                    objbgd.CO = dt.Rows[0]["LCO"].ToString().Trim();
                    objbgd.lamda = dt.Rows[0]["HLAMDA"].ToString().Trim();

                    objbgd.GHCXZ = "50";// dt.Rows[0][""].ToString().Trim();
                    objbgd.GCOXZ = "0.3";// dt.Rows[0][""].ToString().Trim();
                    objbgd.HCXZ = "80";// dt.Rows[0][""].ToString().Trim();
                    objbgd.COXZ = "0.6";// dt.Rows[0][""].ToString().Trim();
                    objbgd.lamdaXZ = "0.95-1.05";//dt.Rows[0][""].ToString().Trim();
                }
                else if (dt.Rows[0]["InspectionMethod"].ToString().Trim().Contains("B"))
                {
                    objbgd.JCFF = string.Format("ASM工况法");
                    objbgd.ASM25CO = dt.Rows[0]["COER5025"].ToString().Trim();
                    objbgd.ASM25HC = dt.Rows[0]["HCER5025"].ToString().Trim();
                    objbgd.ASM25NO = dt.Rows[0]["NOER5025"].ToString().Trim();
                    objbgd.ASM40CO = dt.Rows[0]["COER2540"].ToString().Trim();
                    objbgd.ASM40HC = dt.Rows[0]["HCER2540"].ToString().Trim();
                    objbgd.ASM40NO = dt.Rows[0]["NOER2540"].ToString().Trim();
                    objbgd.ASM25COXZ = "0.5";// dt.Rows[0][""].ToString().Trim();
                    objbgd.ASM25HCXZ = "90";// dt.Rows[0][""].ToString().Trim();
                    objbgd.ASM25NOXZ = "700";// dt.Rows[0][""].ToString().Trim();
                    if (dt.Rows[0]["COER2540"].ToString().Trim().Length > 0)
                    {
                        objbgd.ASM40COXZ = "0.4";// dt.Rows[0][""].ToString().Trim();
                        objbgd.ASM40HCXZ = "80";// dt.Rows[0][""].ToString().Trim();
                        objbgd.ASM40NOXZ = "650";// dt.Rows[0][""].ToString().Trim();
                    }
                }
                else if (dt.Rows[0]["InspectionMethod"].ToString().Trim().Contains("G"))
                {
                    objbgd.JCFF = string.Format("加载减速法");
                    objbgd.K100 = dt.Rows[0]["ER1"].ToString().Trim();
                    objbgd.K80 = dt.Rows[0]["ER3"].ToString().Trim();
                    objbgd.NOX80 = dt.Rows[0]["ERNO3"].ToString().Trim();
                    objbgd.VELMaxHP = dt.Rows[0]["velmaxhp"].ToString().Trim();
                    objbgd.SCGL = dt.Rows[0]["SKPower"].ToString().Trim();

                    objbgd.K100XZ = "1.2";// dt.Rows[0][""].ToString().Trim();
                    objbgd.K80XZ = "1.2";// dt.Rows[0][""].ToString().Trim();
                    objbgd.NOX80XZ = "1500";// dt.Rows[0][""].ToString().Trim();
                    objbgd.GLXZ = fglxz.ToString();// dt.Rows[0][""].ToString().Trim();
                }
                else if (dt.Rows[0]["InspectionMethod"].ToString().Trim().Contains("F"))
                {
                    objbgd.JCFF = string.Format("自由加速法");
                    objbgd.K1 = dt.Rows[0]["A_BZY1"].ToString().Trim();
                    objbgd.K2 = dt.Rows[0]["A_BZY2"].ToString().Trim();
                    objbgd.K3 = dt.Rows[0]["A_BZY3"].ToString().Trim();
                    objbgd.KAVG = dt.Rows[0]["A_BZYAVG"].ToString().Trim();
                    objbgd.SCZS = dt.Rows[0]["A_BZS"].ToString().Trim();

                    objbgd.KXZ = "1.2";// dt.Rows[0][""].ToString().Trim();
                }
                objbgd.wendu = dt.Rows[0]["GasWenDu"].ToString().Trim();
                objbgd.shidu = dt.Rows[0]["GasShiDu"].ToString().Trim();
                objbgd.dqiya = dt.Rows[0]["GasYaLi"].ToString().Trim();
                objbgd.wqpd1 = false;// dt.Rows[0]["WQPD"].ToString().Trim().ToUpper() == "TRUE" ? true : false;
                objbgd.wqpd2 = false;//!objbgd.wqpd1;

            }
            return objbgd;
        }

        public string gethpys(string data)
        {
            string result = "";
            if (data.Contains("01"))
            {
                result = "蓝色";
            }
            else if (data.Contains("02"))
            {
                result = "黄色";
            }
            else if (data.Contains("03"))
            {
                result = "黑色";
            }
            else if (data.Contains("04"))
            {
                result = "白色";
            }
            else if (data.Contains("05"))
            {
                result = "绿色";
            }
            else if (data.Contains("06"))
            {
                result = "黄绿色";
            }
            return result;
        }

        public string getgyfs(string data)
        {
            string result = "";
            if (data.Contains("01"))
            {
                result = "化油器";
            }
            else if (data.Contains("02"))
            {
                result = "闭循电喷";
            }
            else if (data.Contains("03"))
            {
                result = "开环电喷";
            }
            return result;
        }

        public override string upzjgcsj(model.尾气自检.zjgcsj objgcsj)
        {
            string sreturn = "";
            for (int i = 0; i < objgcsj.icount; i++)
            {
                var obj = new 联网通信协议.云景model.HJ37()
                {
                    StationCode = m_mainform.stationCode,
                    SceneCode = m_mainform.lineCode,
                    CheckDate = objgcsj.dtCheckDate,
                    CheckType = objgcsj.szCheckType,
                    CheckTimeStart = objgcsj.dtBeginTime,
                    CheckTimeEnd = objgcsj.dtEndTime,
                    Second_NO = (i + 1).ToString(),
                    RotarySpeed = objgcsj.stringRpt.Count > 0 ? objgcsj.stringRpt[i].ToString("0") : "",
                    PLHP = objgcsj.stringLodVal.Count > 0 ? objgcsj.stringLodVal[i].ToString("0") : "",
                    HC = objgcsj.stringHC.Count > 0 ? objgcsj.stringHC[i].ToString("0") : "",
                    CO = objgcsj.stringCO.Count > 0 ? objgcsj.stringCO[i].ToString("0.00") : "",
                    NO = objgcsj.stringNO.Count > 0 ? objgcsj.stringNO[i].ToString("0") : "",
                    NO2 = "",
                    CO2 = objgcsj.stringCO2.Count > 0 ? objgcsj.stringCO2[i].ToString("0.00") : "",
                    O2 = "",
                };
                string svalue = JsonConvert.SerializeObject(obj);
                string jieguo = senddate("HJ37", svalue);
                sreturn = sreturn + jieguo + "\r\n";
                //return jieguo;
            }
            return sreturn;
        }

    }
}
